[英]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'.我必须将文件上传到期望内容类型为“图像/jpeg”的 api。
Using formData seems to set the content-type as 'multipart-formdata'.使用 formData 似乎将内容类型设置为“multipart-formdata”。 How do I get around this?
我该如何解决这个问题? Can I upload the file without using formData?
我可以在不使用 formData 的情况下上传文件吗?
You may want to try out by setting the content-type
with the example on the link.您可能希望通过使用链接上的示例设置
content-type
来尝试。 All you need to do is use new Blob({jsonStringifiedValues}, {type:'image/jpeg'}
您需要做的就是使用
new Blob({jsonStringifiedValues}, {type:'image/jpeg'}
Well documented on: https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects有据可查: https : //developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.