且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Node js 中使用 Content-Type: application/octet-stream 发送 POST 请求文件

更新时间:2022-06-05 07:16:36

如果您将数据作为表单的一部分上传,则必须将 multipart/form-data 用于您的 Content-输入.

If you're uploading data as part of a form, you must use multipart/form-data for your Content-Type.

表单上特定文件的 Content-Type 可以为每个文件设置,但 Facebook 似乎不希望为此提供额外的数据.

The Content-Type for a particular file on a form can be set per-file, but it seems that Facebook doesn't want that extra data for this.

不要为你的 HTTP 请求设置 Content-Type ,你应该没问题,因为请求模块会为你设置它.此外,您可以在此处找到文档:https://github.com/request/request#multipartform-data-multipart-form-uploads

Don't set Content-Type for your HTTP request and you should be fine, as the Request module will set it for you. Also, you can find the documentation here: https://github.com/request/request#multipartform-data-multipart-form-uploads