PRIZ ;]
PRIZ ;]
TTCTheo's Typesafe Cult
Created by PRIZ ;] on 3/28/2024 in #questions
axios + multipart/formdata
pardon my stupidity, i'm coming from python :P how do i specify Content-Type and filename in Axios.js multipart formdata? python is like this:
url = 'http://httpbin.org/post'
data = aiohttp.FormData()
data.add_field('file',
open('report.xls', 'rb'),
filename='report.xls',
content_type='application/vnd.ms-excel')

await session.post(url, data=data)
url = 'http://httpbin.org/post'
data = aiohttp.FormData()
data.add_field('file',
open('report.xls', 'rb'),
filename='report.xls',
content_type='application/vnd.ms-excel')

await session.post(url, data=data)
which would produce something like
Content-Disposition: form-data; name="file"; filename="report.xls"
Content-Type: application/vnd.ms-excel

[binary data]
Content-Disposition: form-data; name="file"; filename="report.xls"
Content-Type: application/vnd.ms-excel

[binary data]
i just don't know how to specify it in Axios.js since there is no documentation for it: https://axios-http.com/docs/multipart [just has field name and blob data]
3 replies