How to read formData field from http-request in node.js?
I have method that upload files to nodeJS. But now, I want to send the files and another data:
formData.append('files', files[i], filename); --> OK
Now, I add this:
formData.append('ORIGIN', origin_array);
I send data like this:
this.http.post(url, formData, options).pipe(map(result => result))
In nodeJS, I am using "multer" library for get files, and it is OK, but I don't know how to get origin item.
In node, I have this code:
module.exports = {
uploadMultimedia: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).single('file'),
uploadMultimediaArray: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).array('files', 10)
}
And this is my API who calls multer:
exports.multimedia = function (req, res) {
//CODE
}
Sorry about my english.
node.js form-data
add a comment |
I have method that upload files to nodeJS. But now, I want to send the files and another data:
formData.append('files', files[i], filename); --> OK
Now, I add this:
formData.append('ORIGIN', origin_array);
I send data like this:
this.http.post(url, formData, options).pipe(map(result => result))
In nodeJS, I am using "multer" library for get files, and it is OK, but I don't know how to get origin item.
In node, I have this code:
module.exports = {
uploadMultimedia: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).single('file'),
uploadMultimediaArray: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).array('files', 10)
}
And this is my API who calls multer:
exports.multimedia = function (req, res) {
//CODE
}
Sorry about my english.
node.js form-data
Can you post how the code on your node server looks like when you get the post request? I am guessing you can access theORIGIN
by doing something like this:request.getParameter("ORIGIN");
– John
Nov 21 '18 at 11:17
Maybe this answer can help you? stackoverflow.com/questions/4295782/…
– John
Nov 21 '18 at 11:20
@John 1 - req.getParameter returns "req.getParameter is not a function" 2- My body is empty :(
– oihi08
Nov 21 '18 at 11:26
I do not know the exact syntax, but have a look at the answer I linked to. Maybe it can be of help
– John
Nov 21 '18 at 11:27
But I send a FormData not a form
– oihi08
Nov 21 '18 at 11:29
add a comment |
I have method that upload files to nodeJS. But now, I want to send the files and another data:
formData.append('files', files[i], filename); --> OK
Now, I add this:
formData.append('ORIGIN', origin_array);
I send data like this:
this.http.post(url, formData, options).pipe(map(result => result))
In nodeJS, I am using "multer" library for get files, and it is OK, but I don't know how to get origin item.
In node, I have this code:
module.exports = {
uploadMultimedia: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).single('file'),
uploadMultimediaArray: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).array('files', 10)
}
And this is my API who calls multer:
exports.multimedia = function (req, res) {
//CODE
}
Sorry about my english.
node.js form-data
I have method that upload files to nodeJS. But now, I want to send the files and another data:
formData.append('files', files[i], filename); --> OK
Now, I add this:
formData.append('ORIGIN', origin_array);
I send data like this:
this.http.post(url, formData, options).pipe(map(result => result))
In nodeJS, I am using "multer" library for get files, and it is OK, but I don't know how to get origin item.
In node, I have this code:
module.exports = {
uploadMultimedia: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).single('file'),
uploadMultimediaArray: multer({
storage: storage,
limits: {
fieldNameSize: 1 * 1024 * 1024,
fileSize: 1000 * 1024 * 1024 // 5000MB
}
}).array('files', 10)
}
And this is my API who calls multer:
exports.multimedia = function (req, res) {
//CODE
}
Sorry about my english.
node.js form-data
node.js form-data
edited Nov 21 '18 at 11:23
John
2,73512139
2,73512139
asked Nov 21 '18 at 11:14
oihi08oihi08
1901113
1901113
Can you post how the code on your node server looks like when you get the post request? I am guessing you can access theORIGIN
by doing something like this:request.getParameter("ORIGIN");
– John
Nov 21 '18 at 11:17
Maybe this answer can help you? stackoverflow.com/questions/4295782/…
– John
Nov 21 '18 at 11:20
@John 1 - req.getParameter returns "req.getParameter is not a function" 2- My body is empty :(
– oihi08
Nov 21 '18 at 11:26
I do not know the exact syntax, but have a look at the answer I linked to. Maybe it can be of help
– John
Nov 21 '18 at 11:27
But I send a FormData not a form
– oihi08
Nov 21 '18 at 11:29
add a comment |
Can you post how the code on your node server looks like when you get the post request? I am guessing you can access theORIGIN
by doing something like this:request.getParameter("ORIGIN");
– John
Nov 21 '18 at 11:17
Maybe this answer can help you? stackoverflow.com/questions/4295782/…
– John
Nov 21 '18 at 11:20
@John 1 - req.getParameter returns "req.getParameter is not a function" 2- My body is empty :(
– oihi08
Nov 21 '18 at 11:26
I do not know the exact syntax, but have a look at the answer I linked to. Maybe it can be of help
– John
Nov 21 '18 at 11:27
But I send a FormData not a form
– oihi08
Nov 21 '18 at 11:29
Can you post how the code on your node server looks like when you get the post request? I am guessing you can access the
ORIGIN
by doing something like this: request.getParameter("ORIGIN");
– John
Nov 21 '18 at 11:17
Can you post how the code on your node server looks like when you get the post request? I am guessing you can access the
ORIGIN
by doing something like this: request.getParameter("ORIGIN");
– John
Nov 21 '18 at 11:17
Maybe this answer can help you? stackoverflow.com/questions/4295782/…
– John
Nov 21 '18 at 11:20
Maybe this answer can help you? stackoverflow.com/questions/4295782/…
– John
Nov 21 '18 at 11:20
@John 1 - req.getParameter returns "req.getParameter is not a function" 2- My body is empty :(
– oihi08
Nov 21 '18 at 11:26
@John 1 - req.getParameter returns "req.getParameter is not a function" 2- My body is empty :(
– oihi08
Nov 21 '18 at 11:26
I do not know the exact syntax, but have a look at the answer I linked to. Maybe it can be of help
– John
Nov 21 '18 at 11:27
I do not know the exact syntax, but have a look at the answer I linked to. Maybe it can be of help
– John
Nov 21 '18 at 11:27
But I send a FormData not a form
– oihi08
Nov 21 '18 at 11:29
But I send a FormData not a form
– oihi08
Nov 21 '18 at 11:29
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410923%2fhow-to-read-formdata-field-from-http-request-in-node-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410923%2fhow-to-read-formdata-field-from-http-request-in-node-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you post how the code on your node server looks like when you get the post request? I am guessing you can access the
ORIGIN
by doing something like this:request.getParameter("ORIGIN");
– John
Nov 21 '18 at 11:17
Maybe this answer can help you? stackoverflow.com/questions/4295782/…
– John
Nov 21 '18 at 11:20
@John 1 - req.getParameter returns "req.getParameter is not a function" 2- My body is empty :(
– oihi08
Nov 21 '18 at 11:26
I do not know the exact syntax, but have a look at the answer I linked to. Maybe it can be of help
– John
Nov 21 '18 at 11:27
But I send a FormData not a form
– oihi08
Nov 21 '18 at 11:29