1
I have an application that is being written using Node.Js, in which 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.: 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 it receives the data in an address like: application.com.br/v1/videos. I don’t have access to which folder will be saved or the communication port. And it still needs to send parameters in the header and the request body.
Edit 1: I was able to request using the module request. The problem is that I need to add an integer parameter to the request body. "testeId": 7451109
. How to proceed? Following 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);
});
As I said in the question, I am not using Express. But thanks for the answer!
– lys
No need to use express, I put up an example of code used the default http of Node.
– Wanderson Aparecido
In the case of my server, it is already running on the internet, a site like app.com.br/v1/videos. I don’t have the communication port. Is there still a way to use the multer? If so, how to proceed?
– lys