简体   繁体   中英

how to Upload a file using axios without using formdata api?

I have to upload a file to an api that expects content type to be 'image/jpeg'.
Using formData seems to set the content-type as 'multipart-formdata'. How do I get around this? Can I upload the file without using formData?

You may want to try out by setting the content-type with the example on the link. All you need to do is use new Blob({jsonStringifiedValues}, {type:'image/jpeg'}

Well documented on: https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM