How to send multipart/form-data with antd upload react

旧时模样 提交于 2021-02-10 06:31:12

问题


I am using react and antd.
The component I am using from antd is Drag and Drop.
I am trying to send multipart/form-data using FormData object.
It sends the file (.zip file that should be sent as blob) but it does not send it as blob nor anything related to the other keys and values.
Here's a Sandbox.

Expected Request Payload:

------WebKitFormBoundaryysdTGvf0cRZVGpQ4
Content-Disposition: form-data; name="file"; filename="aFileName.zip"
Content-Type: application/octet-stream

[0,1,2]
------WebKitFormBoundaryysdTGvf0cRZVGpQ4
Content-Disposition: form-data; name="x2"

y2
------WebKitFormBoundaryysdTGvf0cRZVGpQ4
Content-Disposition: form-data; name="x3"

true
------WebKitFormBoundaryysdTGvf0cRZVGpQ4
Content-Disposition: form-data; name="x4"

2
------WebKitFormBoundaryysdTGvf0cRZVGpQ4

Actual Request Paylod:

------WebKitFormBoundaryysdTGvf0cRZVGpQ4
Content-Disposition: form-data; name="file"; filename="aFileName.zip"
Content-Type: application/zip


------WebKitFormBoundaryysdTGvf0cRZVGpQ4

回答1:


I have used customRequest to solve this problem.
You can find an example here: Send multipart/form-data with antd upload #11616



来源:https://stackoverflow.com/questions/51697944/how-to-send-multipart-form-data-with-antd-upload-react

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!