4

Sails.js プロジェクトにマルチパート フォームがあり、いくつかのテキストパラメータと共に 2 つの異なるファイル (最初にaudio、次にimage ) を送信します。ファイルがかなり小さい場合、ほとんどの場合、すべて正常に動作します。しかし、より大きなオーディオ ファイル ( 33MB ) を試したところ、受信側のイメージ フィールドに空のファイル配列が作成されました。ここにいくつかのコードがあります。

コントローラー:

var uploadParamNames = ['audio', 'image'];

async.map(uploadParamNames, 
    function (file, cb) {

       sails.log(req.file(file)._files)
       req.file(file).upload(
       {
           adapter:     require('skipper-gridfs'),
           uri:         sails.config.connections.mongoConnection.url + '.' + file           
       }, 
       function (err, files) {
           // save the file, and then:
           return cb(err, files);
    });

}, function doneUploading(err, files) {
...
});

基本的にここで、音声と画像の次のログを取得します。

[ { stream: [Object], status: 'bufferingOrWriting' } ]
[]

デバッグを試みたところ、画像フィールドの場合、ファイルが実際にprototype.onFile.js行に書き込まれている行に到達しないことがわかりましたup.writeFile(part);

また、デバッグ ログには次のように出力されます。

Parser: Read a chunk of textparam through field `_csrf`
Parser: Read a chunk of textparam through field `ss-name`
Parser: Read a chunk of textparam through field `ss-desc`
Parser: Read a chunk of textparam through field `ss-category`
Parser: Read a chunk of textparam through field `ss-language`
Parser: Read a chunk of textparam through field `ss-place`
Parser: Read a chunk of textparam through field `ss-place-lat`
Parser: Read a chunk of textparam through field `ss-place-lon`
Acquiring new Upstream for field `audio`
Tue, 13 Oct 2015 10:52:54 GMT skipper Set up "maxTimeToWaitForFirstFile" timer for 10000ms
Tue, 13 Oct 2015 10:52:58 GMT skipper passed control to app because first file was received
Tue, 13 Oct 2015 10:52:58 GMT skipper waiting for any text params
Upstream: Pumping incoming file through field `audio`
Parser: Done reading textparam through field `_csrf`
Parser: Done reading textparam through field `ss-name`
Parser: Done reading textparam through field `ss-desc`
Parser: Done reading textparam through field `ss-category`
Parser: Done reading textparam through field `ss-language`
Parser: Done reading textparam through field `ss-tags`
Parser: Done reading textparam through field `ss-place`
Parser: Done reading textparam through field `ss-place-lat`
Parser: Done reading textparam through field `ss-place-lon`
Tue, 13 Oct 2015 10:53:11 GMT skipper Something is trying to read from Upstream `audio`...
Tue, 13 Oct 2015 10:53:11 GMT skipper Passing control to app...
Tue, 13 Oct 2015 10:53:16 GMT skipper maxTimeToWaitForFirstFile timer fired- as of now there are 1 file uploads pending (so it's fine)
debug: [ { stream: [Object], status: 'bufferingOrWriting' } ]
Tue, 13 Oct 2015 10:53:41 GMT skipper .upload() called on upstream
Acquiring new Upstream for field `image`
Tue, 13 Oct 2015 10:53:46 GMT skipper Set up "maxTimeToWaitForFirstFile" timer for 10000ms
debug: []

理由はわかりませんが、画像ファイルが書き込まれる前に、コントロールが既にアプリに渡されているようです。繰り返しますが、これはより大きなオーディオ ファイルでのみ発生します。これを修正する方法はありますか?

EDIT: さらにデバッグすると、receivedFirstFileOfRequest画像ファイルが書き込まれる前にリスナーが呼び出されることが示されました。最初のファイルのアップロードを実際にリッスンするため、どちらが論理的ですが、次のファイルをどうするか?

編集: ああ...ファイルは非常に大きくする必要はまったくありません。29KB のファイルは通過し、320KB は通過しません...

4

0 に答える 0