How to use multipart/form-data
ASaiAnudeep opened this issue · comments
Anudeep commented
Hi,
I am trying to make a request with multipart/form-data. Is it possible to send such requests in phin.
Can I use form-data in phin??
ThatTonybo commented
As far as I'm aware either parse a JSON object in the request's { data }
field, or you could try using form-data. Just set the request header to indicate so.
Anudeep commented
I was able to use form-data
with the following code:
const options = {};
const form = new FormData();
form.append('my_file', fs.readFileSync(path), { contentType: 'application/xml', filename: 'jUnit.xml' });
options.data = form.getBuffer();
options.headers = form.getHeaders();
phin(options)