i have a node js module that recives an writes file chunks in a temp folder.
server.route([
{
method: "POST",
path: "/api/upload_big_files",
config:{
payload:{
maxBytes: 200000000
},
auth: 'jwt'
},
handler: function(request, reply){
const file = request.payload;
const query = request.query;
fs.writeFile(big_files_tmp_path+query.file_name+'/'+query.file_name+'.part'+file._chunkNumber, file.upload, (err) => {
if (err) throw err;
var current_size = parseInt(file._chunkNumber) * parseInt(file._chunkSize);
if(current_size + parseInt(file._currentChunkSize) >= parseInt(file._totalSize)){
}else{
reply(query.file_name+'.part'+file._chunkNumber + " has been saved").code(200)
}
});
}
}
]);
now i want to reassemble the file once all of the chunks have been uploaded, what is the best way to achieve this? since this module will be recieving several big files at a time it requires a way to avoid memory issues.
thanks in advance to anyone who can help!
via fr3d0
No comments:
Post a Comment