我使用存储库 here中的示例使用express-busboy设置文件上载 这似乎没有使用正常的use()语法,所以我有点困惑如何实际限制这个中间件,所以它只在特定的路由上执行,因为它打破了其他POST请
这似乎没有使用正常的use()语法,所以我有点困惑如何实际限制这个中间件,所以它只在特定的路由上执行,因为它打破了其他POST请求.
这是我配置它的方式:
var busboy = require('express-busboy');
busboy.extend(app, {
upload: true,
path: '.http://img.558idc.com/uploadfile/temp'
});
在allowedPath值中,您可以在明确应用程序中定义的后路由中指定此案例限制中的正则表达式.喜欢/上传
busboy.extend(app, {
upload: true,
path: '.http://img.558idc.com/uploadfile/temp',
allowedPath: /^\http://img.558idc.com/uploadfile$/
});
或者其他方面你可以通过功能
var options = {
upload: true,
path: '.http://img.558idc.com/uploadfile/temp',
};
options.allowedPath = function(url) {
return url == '/api/ccUpload';
}
busboy.extend(app, options);
