【问题标题】:upload file from angular app to an azure function and then persist to blob storage将文件从 Angular 应用程序上传到 azure 函数,然后持久保存到 blob 存储
【发布时间】: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


    【解决方案1】:

    这里是 a sample GIT project,它使用 @azure/storage-blob SDK 将 blob 添加到 Azure。听起来您不想使用 SDK,因此您可以查看 SDK 源代码并获取所需的代码。

    【讨论】:

    猜你喜欢
    • 2021-04-30
    • 1970-01-01
    • 2023-02-01
    • 2017-01-24
    • 2017-08-19
    • 2021-03-07
    • 2020-09-21
    • 2020-08-25
    • 1970-01-01
    相关资源
    最近更新 更多