Node JS中的multipart / formData请求

时间:2018-07-10 22:01:50

标签: node.js multipartform-data

我对节点js的multipart / formdata请求不满意。

我正在抓取一个执行multipart / formdata请求的网站。这是这样的:

url : https://example.com
Content-Type: multipart/form-data;boundary=----

formdata : 
    Content-Disposition: form-data; name=field1
    value1

    Content-Disposition: form-data; name=field1
    value1

    Content-Disposition: form-data; name=field2
    value2

    Content-Disposition: form-data; name=field3
    value3

    Content-Disposition: form-data; name=field4
    value4

    Content-Disposition: form-data; name=^\^"theFile^\^"; filename=^\^"^\^"^
    Content-Type: application/octet-stream^

我正在使用节点js的请求模块来执行此操作。就是这样

 var options = { 
               method: 'POST',
               url: "https://example.com",
               formData : {
                           "field1" : "value1",
                           "field2" : "value2",
                           "field3" : "value3",
                           "field4" : "value4",
                           "theFile": {
                               "value":  "",
                               "options": {
                                    "filename": '',
                                    "contentType": 'application/octet-stream'
                               }
                          }
               }
}

我在哪里做错了?

0 个答案:

没有答案