aheckmann / gridfs-stream

Easily stream files to and from MongoDB
MIT License
615 stars 120 forks source link

v0.4 Receive wrong file size when use options.range #66

Closed Alex-us closed 9 years ago

Alex-us commented 9 years ago

Hi, I found strange behavior when using options.range. Collection in DB: { "_id" : ObjectId("54c4d7c6849b10b54af4ac23"), "filename" : "lighter_250115.mp4", "contentType" : "video/mp4", "length" : 3116025, "chunkSize" : 261120, "uploadDate" : ISODate("2015-01-25T11:47:18.416Z"), "aliases" : null
}

Getting part of file: var options = {_id : 54c4d7c6849b10b54af4ac23}; options.range ={ startPos: 26104, endPos: 3116024 };

gfs.createReadStream(options) .on('error', onError) .pipe(response);

Then actual behavior is following: Expected file size: 3089921 Actual sent size: 3096321

Also changing the startPos value doesn't affect result file size.

Alex-us commented 9 years ago

Upgraded to version 1.0.1 - the problem has gone.