Using form-data with request, question about boundary
See original GitHub issueHi,
I’m using form-data with request module, and I want to use a custom boundary.
I want my request to look like :
------WebKitFormBoundaryCIkXuNWC8OhEuT3S
Content-Disposition: form-data; name="file"; filename="myfile.pdf"
Content-Type: application/pdf
FILE_CONTENT
------WebKitFormBoundaryCIkXuNWC8OhEuT3S
Content-Disposition: form-data; name="submitfile"
Télécharger
------WebKitFormBoundaryCIkXuNWC8OhEuT3S--
Here is what my code looks like :
var boundary = "------WebKitFormBoundaryUucA6DiAhQeYNgIm";
options["preambleCRLF"] = true ;
options["postambleCRLF"] = true ;
var formData = {
'file': fs.createReadStream(filePath),
'submitfile' : 'Télécharger',
boundary : boundary
};
options["formData"] = formData ;
request.post(options, function(err, resp, body){
...
But It’s not working, I 'm sending this :
----------------------------063289265105652106385340
Content-Disposition: form-data; name="file"; filename="myfile.pdf"
Content-Type: application/pdf
FILE_CONTENT
In the form-data doc I saw something interesting for my problem :
var CRLF = '\r\n';
var form = new FormData();
var options = {
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
knownLength: 1
};
But since I’m using it with request I don’t really know how could I do this.
Thank you
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
What is the boundary in multipart/form-data? - Stack Overflow
Great answer. A boundary is just the 'key' to separate the multiple "parts" of a multipart payload. Normally something like '&' is enough...
Read more >How to get or set boundary in multipart/form-data from ... - Dirask
Any idea how to get or set boundary for FormData ? At this moment there is no way to set up boundary for...
Read more >Question: How to upload a file using HTTP POST Form-Data?
I want to upload a file using HTTP POST where username and password are to be filled using form-data. It works well from...
Read more >I have a requirement to send a multipart form-data via HTTP ...
I have a requirement to send a multipart form-data via HTTP request and send the header as Content-Type with application/form-data and ...
Read more >jQuery : How to set a boundary on a multipart/form ... - YouTube
jQuery : How to set a boundary on a multipart/ form-data request while using jquery ajax FormData () with multiple files [ Beautify...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there a working solution to this issue?
@ksahin did your problem solved ? I am also facing the same issue.