0

我正在尝试使用 slingshot 包在流星中进行文件上传。它适用于单个文件。但我的要求是我正在使用多个文件输入,并且对于每个文件输入,我想将文件发送到 s3。这是我的客户端/upload.js

'click #saveImgs': function(e) {
  for(var i=1; i<6;i++){
    var fileList= document.getElementById('file_'+i);
    var f= fileList.files[0];
    if(f){
      var uploader = new Slingshot.Upload("images");          
      uploader.send(f, function (error, downloadUrl) {
        if (error) {
          alert(error);
            console.error('Error uploading', uploader.xhr.response);
        }
        else {
          console.log(downloadUrl);
        }
      });     
    }
    else{
      alert("no file");
    }       
  } 
}

我的upload.html是这样的:

<h3>Multiple upload</h3>
<br>
<input type=file id="file_1" />

<br>
<input type=file id="file_2" />

<br>
<input type=file id="file_3" />

<br>
<input type=file id="file_4" />

<br>
<input type=file id="file_5" />

<br>
<input type=button value="Upload" id="saveImgs" />

它返回第一次上传的 url,但之后它给出异常并中断下一个进程。

I20150408-15:06:42.169(5.5)? Exception while invoking method 'slingshot/uploadRequest' Error: Did not check() all arguments during call to 'slingshot/uploadRequest'
I20150408-15:06:42.169(5.5)?     at [object Object]._.extend.throwUnlessAllArgumentsHaveBeenChecked (packages/check/match.js:357:1)
I20150408-15:06:42.169(5.5)?     at Object.Match._failIfArgumentsAreNotAllChecked (packages/check/match.js:112:1)
I20150408-15:06:42.169(5.5)?     at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1614:1)
I20150408-15:06:42.170(5.5)?     at packages/ddp/livedata_server.js:648:1
I20150408-15:06:42.170(5.5)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150408-15:06:42.170(5.5)?     at packages/ddp/livedata_server.js:647:1
I20150408-15:06:42.170(5.5)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150408-15:06:42.170(5.5)?     at [object Object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:646:1)
I20150408-15:06:42.171(5.5)?     at packages/ddp/livedata_server.js:546:1
4

1 回答 1

1

删除审计参数检查包或检查方法中的所有参数以使其工作。

(使其成为官方答案)

于 2015-04-08T11:52:44.430 回答