question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Send multipart/form-data with antd upload

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.8.0

Environment

react: 16.4.2, antd: 3.8.0, chrome: 67.0.3396.99

Reproduction link

Edit on CodeSandbox

Steps to reproduce

You can find the code with the issue in this sandbox: https://codesandbox.io/s/j3q07kyy8w

What is 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

What is actually happening?

Request Payload:

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


------WebKitFormBoundaryysdTGvf0cRZVGpQ4

This is the question on stackoverflow: https://stackoverflow.com/q/51697944/2648837

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

40reactions
yokyjcommented, Aug 10, 2018

well you may do it in customRequest

		customRequest: (options: any) => {
			const data= new FormData()
			data.append('file', options.file)
			const config= {
				"headers": {
					"content-type": 'multipart/form-data; boundary=----WebKitFormBoundaryqTqJIxvkWFYqvP5s'
				}
			}
			axios.post(options.action, data, config).then((res: any) => {
				options.onSuccess(res.data, options.file)
			}).catch((err: Error) => {
				console.log(err)
			})
			
		},
1reaction
raconstructcommented, Mar 10, 2021

Hi @Mohamed-Ghanem The Code sandbox not working Man

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to send multipart/form-data with antd upload react
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...
Read more >
Reactjs – How to send multipart/form-data with antd upload react
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...
Read more >
How to Multipart File Upload Using FormData with React Hook ...
In this guide, I'm going to show you how to multipart files upload with using React Hook Form.
Read more >
Upload - Ant Design
Uploading is the process of publishing information (web pages, text, pictures, video, etc.) to a remote server via a web page or upload...
Read more >
How to Upload Files in .NET core Web API and React
File Upload in SPA(Single Page Application) sometimes raises more ... body and it's encoded, sent out with Content-Type : multipart/form-data which should ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found