I'm using this function to retrieve the file. there are some other function calls before that pulls the md5sum out of the request, makes sure the file exists, then calls buildFile().
FileChunker.prototype.buildFile = function(file, callback) {
self = this;
console.log(file);
this.gridfs.get(file._id, function(error, data) {
if (error) {
console.log(error);
callback(error);
}
else {
callback(null, data);
}
});
};
here's the resulting hexdumps.
original file on disk (imported via mongofiles, can be properly retrieved via mongofiles)
~/_nodejs% hexdump -C test.txt
00000000 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 |ABCDEFGHIJKLMNOP|
00000010 0a |.|
00000011
output from nodejs
~/_nodejs% hexdump -C OUTPUT
00000000 11 00 00 00 41 42 43 44 45 46 47 48 49 4a 4b 4c |....ABCDEFGHIJKL|
00000010 4d |M|
00000011
if we console.log
the Buffer object, we see the extra data as well:
<Buffer 11 00 00 00 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d>
I've been smashing my head against this for some time and have no idea what to do next. it's like the gridfs.get()
is just returning the wrong data.