I have an application that is being written using Node.Js, in it I use FFmpeg to create a video from a webcam. I need to upload it to the server using a POST request. So the question is:
How to upload a video using multipart and Node.js?
Ps1 .: The video is a local file whose path will be passed by parameter! Creating a form to choose the file is not the answer.
Ps2: I'm not using Express.
Ps3 .: The server runs on the internet, for this request receives the data in an address as: application.com.br/v1/videos. I have no access in which folder will be saved nor the port of communication. And it still needs to send parameters in the header and body of the request.
Edit 1: I was able to do the request using the request module. The problem is that I need to append an integer parameter in the request body. "testeId": 7451109
. How to proceed? Follow the code so far.
Edit 2: Updating the code.
Code:
request({
method: "POST",
url: "https://" + options.host + options.path,
formData: {
upload_type: "mp4",
file: fs.createReadStream(options.nomeVideo)
},
headers: {
'Content-Type': 'multipart/form-data',
'access-token': chaveCriptografada
}
},
function (error, response, body) {
console.log(error);
console.log(response);
console.log(body);
});