0

この関数を使用してファイルを取得しています。リクエストから md5sum を取得し、ファイルが存在することを確認してから、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);
                 }       
         });     
    }; 

結果の16進ダンプは次のとおりです。

ディスク上の元のファイル (mongofiles を介してインポートされ、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

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

Buffer オブジェクトの場合console.log、追加のデータも表示されます。

 <Buffer 11 00 00 00 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d>

私はしばらくこれに頭を悩ませてきましたが、次に何をすべきかわかりません。gridfs.get()間違ったデータを返すだけのようです。

4

1 に答える 1