sails.js - Using Sailsjs Skipper file uploading with Flowjs -


i'm trying use skipper , flowjs ng-flow big file uploading.

based on sample nodejs located in flowjs repository, i've created sails controller , service handle file uploads. when uploading small file it's works fine, if try upload bigger file (e.g. video of 200 mb) i'm receiving errors (listed below) , array req.file('file')._files empty. intersting fact happening few times during uploading. example, if flowjs cut file 150 chunks, in sails console these errors appear 3-5 times. so, chunks uploaded server, few lost , in result file corrupted.

verbose: unable expose body parameter `flowchunknumber` in streaming upload! client tried send text parameter (flowchunknumber) after 1 or more files had been sent. make sure send text params first, files. 

these errors appears flowjs parameters.

i know text parameters must sent first correct work skipper. , in chrome network console i've checked flowjs sends data in correct order.

any suggestions?

controller method

upload: function (req, res) {   flow.post(req, function (status, filename, original_filename, identifier) {     sails.log.debug('flow: post', status, original_filename, identifier);     res.status(status).send();   }); } 

service post method

$.post = function(req, callback)  {  var fields = req.body; var file = req.file($.fileparametername); if (!file || !file._files.length) {   console.log('no file', req);   file.upload(function() {}); } var stream = file._files[0].stream;  var chunknumber = fields.flowchunknumber; var chunksize = fields.flowchunksize; var totalsize = fields.flowtotalsize; var identifier = cleanidentifier(fields.flowidentifier); var filename = fields.flowfilename;  if (file._files.length === 0 || !stream.bytecount) {   callback('invalid_flow_request', null, null, null);   return; }  var original_filename = stream.filename; var validation = validaterequest(chunknumber, chunksize, totalsize, identifier, filename, stream.bytecount); if (validation == 'valid') {    var chunkfilename = getchunkfilename(chunknumber, identifier);    // save chunk skipper file upload api   file.upload({saveas:chunkfilename},function(err, uploadedfiles){     // have chunks?     var currenttestchunk = 1;     var numberofchunks = math.max(math.floor(totalsize / (chunksize * 1.0)), 1);     var testchunkexists = function()     {       fs.exists(getchunkfilename(currenttestchunk, identifier), function(exists)       {         if (exists)         {           currenttestchunk++;           if (currenttestchunk > numberofchunks)           {             callback('done', filename, original_filename, identifier);           } else {             // recursion             testchunkexists();           }         } else {           callback('partly_done', filename, original_filename, identifier);         }       });     };     testchunkexists();   }); } else {   callback(validation, filename, original_filename, identifier); }}; 

edit

found solution set flowjs property maxchunkretries: 5, because default it's 0. on server side, if req.file('file')._files empty i'm throwing not permanent(in context of flowjs) error.

so, it's solves problem, question why behave still open. sample code flowjs , nodejs uses connect-multiparty , has no additional error handling code, it's skipper bodyparser bug.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -