我尝试用Express返回一些二进制数据.在示例中,它是PDF,但理论上,它可以是任何类型的文件.
但暂时关注pdf.我写了这段代码:
app.get('*', function (req, res) {
getBinaryData(req.url,
function (answer) {
res.type('pdf');
res.end(new Buffer(answer, 'binary'));
},
function (error) {
res.setHeader('Content-Type', 'text/plain');
return res.end(error);
}
);
});
Run Code Online (Sandbox Code Playgroud)
根据我在这里看到的内容:https://github.com/strongloop/express/issues/1555
但是,我得到一个pdf文件,页面数量正确,标题正确....但所有页面都是空白的
我确定关注getBinaryData()的返回,因为这个函数询问了外部Web服务,当我直接询问这个服务时,我得到了正确的文档.
提前感谢您的回答
我尝试使用 anExceptionFilter将异常映射到它们的 HTTP 对应项。
这是我的代码:
@Catch(EntityNotFoundError)
export class EntityNotFoundFilter implements ExceptionFilter {
catch(exception: EntityNotFoundError, _host: ArgumentsHost) {
throw new NotFoundException(exception.message);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当执行过滤器代码时,我得到了一个 UnhandledPromiseRejectionWarning
(node:3065) UnhandledPromiseRejectionWarning: Error: [object Object]
at EntityNotFoundFilter.catch ([...]/errors.ts:32:15)
at ExceptionsHandler.invokeCustomFilters ([...]/node_modules/@nestjs/core/exceptions/exceptions-handler.js:49:26)
at ExceptionsHandler.next ([...]/node_modules/@nestjs/core/exceptions/exceptions-handler.js:13:18)
at [...]/node_modules/@nestjs/core/router/router-proxy.js:12:35
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)
(node:3065) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: …Run Code Online (Sandbox Code Playgroud) 当我想突出显示一个功能时,我在OpenLayers 3上遇到z-index的麻烦.
我创建了一个国家的GeoJSON形状,在顶部添加了一些标记,我想在我悬停时改变形状颜色.
但是,当颜色变化时,形状隐藏了我的标记.
我尝试将zIndex样式放在hightlight样式上,但这不会改变任何东西......
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})],
controls: ol.control.defaults({
attributionOptions: ({
collapsible: false
})
}),
target: 'map',
view: new ol.View({
center: [631965.84, 4918890.2],
zoom: 3
})
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({}),
style: new ol.style.Style({
zIndex: 1,
stroke: new ol.style.Stroke({
color: '#589CA9',
width: 3
}),
fill: new ol.style.Fill({
color: '#589CA9'
})
})
});
map.addLayer(vector);
var selectPointerMove = new ol.interaction.Select({
condition: ol.events.condition.pointerMove,
style: new ol.style.Style({
stroke: new …Run Code Online (Sandbox Code Playgroud) 我尝试选择除缩小文件之外的所有文件。
我有这个文件结构:
lib/
angular/
angular.js
angular.min.js
lodash/
lodash.js
lodash.min.js
Run Code Online (Sandbox Code Playgroud)
我试试这个:
var pattern = ["./lib/**/*!(.min).*"];
gulp.src(pattern).pipe(using({}));
Run Code Online (Sandbox Code Playgroud)
但这不起作用:我得到了所有文件,即使它们被缩小了。
(通过 gulp-using 我得到:
[gulp] Using file ./lib/angular/angular.js
[gulp] Using file ./lib/angular/angular.min.js
[gulp] Using file ./lib/lodash/lodash.js
[gulp] Using file ./lib/lodash/lodash.min.js
Run Code Online (Sandbox Code Playgroud)
)
任何想法 ?
预先感谢您的帮助
javascript ×2
node.js ×2
binary ×1
express ×1
glob ×1
gulp ×1
minimatch ×1
nestjs ×1
openlayers-3 ×1
pdf ×1
typescript ×1