Node.js Sending Multipart/form-data from server side(backend)

send multipart/formdata

1. form-data:

2. node-fetch:

const FormData = require('form-data');
const http = require('http');
const form = new FormData();
const fs = require('fs');
form.append('file1', 'fileData');
form.append('my_buffer', new Buffer(10)); //appending buffer in key my_buffer
form.append('my_logo', fs.createReadStream('your_image_location')); //appending image in key 'my logo'
const uploadResponse = await fetch(url_to_send_request, {method: 'POST', body: form });
Host: localhost:8000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __atuvc=34%7C7; permanent=0; _gitlab_session=226ad8a0be43681acf38c2fab9497240; __profilin=p%3Dt; request_method=GET
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
Content-Length: 554

Content-Disposition: form-data; name="text"

text default



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store