【发布时间】:2019-06-25 11:54:07
【问题描述】:
我想将图像上传到 azure 函数并将其保存到 azure blob 存储,但我找不到任何关于如何执行此操作的好文章。
有些帖子说不可能这样做,因为节点 azure 函数在多部分方面存在问题。
我不想让我的客户端应用知道使用了什么存储机制,所以我不想使用azure-storage-node 客户端库,因为我们将被锁定使用。
我试过这段代码:
const upload = multer({ storage: multer.memoryStorage() });
module.exports = function(context: Context, req: any) {
upload.any()(req, {} as any, function(err: any) {
context.log('here we are');
if (err) {
throw err;
}
context.log(req.body);
context.log(req);
console.log(req.file);
context.log(req.files);
context.done(undefined, context);
});
但是 req.files 是未定义的,我必须将内容类型设置为application/octet-stream,否则我得到req.pipe is not a function。
如何将 req.files 从 azure 函数获取到 azure 存储?
【问题讨论】:
标签: node.js azure-storage azure-functions azure-blob-storage