I used busboy module to parse multipart request with below coffeeScript code. The problem is, sometimes, on 'data' handler called several times for the request including one file. That means I need to sum to each size to figure the whole size. Besides the file object in the on 'file' handler seems not including size information.
How to get the whole size without calculating each part?
Thanks in advance-
busboy.on 'file', (fieldname, file, filename, encoding, mimetype) ->
filename = "#{Meteor.uuid()}.jpg"
dir = "#{HomeDir()}/data/profile"
saveTo = path.join dir, filename
file.pipe fs.createWriteStream saveTo
files.push
filename: filename
path: saveTo
fileSize: data.length
file.on 'data', (data) ->
# this data handler called several times
files.push
filename: filename
path: saveTo
fileSize: data.length
file.on 'end', ->
console.log 'file finished'