如何使用 HTTP 触发器解析 Azure Function App 中的多部分表单数据?(NodeJS) [英] How to parse Multi-part form data in an Azure Function App with HTTP Trigger? (NodeJS)

查看:13
本文介绍了如何使用 HTTP 触发器解析 Azure Function App 中的多部分表单数据?(NodeJS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Azure Functions 编写一个 NodeJS HTTP 端点.

I want to write a NodeJS HTTP endpoint using Azure Functions.

此端点将是一个 POST 端点,它接收文件并将这些文件上传到 blob 存储.

This endpoint will be a POST endpoint which takes files and upload these to blob storage.

而NodeJS多部分表单数据解析器都是httpserver或者expressJS中间件的形式.

However, NodeJS multipart form data parsers are all in the form of httpserver or expressJS middleware.

是否有任何可用的工具可以在从函数应用程序的包装器接收到多部分表单数据后对其进行解析?

Is there any available tools that can parse the multipart form data after it has all been received from the Function Application's wrapper?

谢谢!

推荐答案

由于 Azure Functions 在 Node.js 中封装了 http server 对象,并公开了一个简单的 reqcontext 具有多个功能,请参阅 https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#exporting-a-function了解详情.

As Azure Functions has wrapped http server object in Node.js, and exposes a simple req and context with several functionalities, refer to https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#exporting-a-function for details.

大部分情况下,Azure Functions 是为触发器和 webhook 请求而设计的,您可以参考 https://docs.microsoft.com/en-us/azure/azure-functions/functions-compare-logic-apps-ms-flow-webjobs 进行详细比较.

And mostly, Azure Functions is designed for triggers and webhooks requests, you can refer to https://docs.microsoft.com/en-us/azure/azure-functions/functions-compare-logic-apps-ms-flow-webjobs for the detailed comparison.

同时,您可以尝试Image的答案在 node.js 中上传到服务器而不使用 express 将请求正文内容解析为文件内容,并利用适用于 node.js 的 Azure Storage SDK 上传到 Azure Storage,您可以通过 KUDU 控制台安装自定义节点模块.参考 https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#node-version--package-management了解更多信息.

Meanwhile, you can try the answer of Image upload to server in node.js without using express to parse the request body content to file content, and upload to Azure Storage leveraging Azure Storage SDK for node.js, you can install custom node modules via KUDU console. Refer to https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#node-version--package-management for more info.

我建议您可以尝试利用 Azure API 应用程序 来接近您的 requiremnet.由于是基于expressjs的项目,上传文件处理起来会更方便.

And I suggest you can try to leverage Azure API App in node.js to approach your requiremnet. As it is an expressjs based project, which will be more easier to handle upload files.

如有任何进一步的问题,请随时告诉我.

Any further concern, please feel free to let me know.

这篇关于如何使用 HTTP 触发器解析 Azure Function App 中的多部分表单数据?(NodeJS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆