2016-08-24 62 views
3

試圖上傳多個圖像文件創建一個多上傳AWSloopback-component-storage環回AWS文件上傳:無法使用S3上

這裏是方法:

Game.add = function(ctx,options,cb) 
     { 
       var status = ctx.req.query.status, 
       defaultLangCode = ctx.req.query.defaultLangCode, 
       nameEn = ctx.req.query.nameEn; 

      var rec = new Object(); 
      rec.parentHouseId = houseId; 
      rec.status = status; 
      rec.defaultLangCode = defaultLangCode; 
      rec.nameEn = nameEn; 

      if(!options) options = {forceIframeTransport : true}; 
      ctx.req.params.container = 'common'; 
      Game.app.models.container.upload(ctx.req,ctx.result,options,function (err,fileObj) { 
       if(err) { 
        cb(err); 
       } else { 
        var fileInfo = fileObj.files.file[0]; 
        console.log(fileInfo); 
       } 
      }); 
     }; 

Game.remoteMethod(
     'add', 
     { 
      http:{path: '/add', verb: 'post', status: 200, errorStatus: 400}, 
      accepts: [ 
       { arg: 'ctx', type: 'object', http: { source:'context' } }, 
       { arg: 'options', type: 'object', http:{ source: 'query'} } 
      ], 
      returns: { 
       arg: 'fileObject', type: 'object', root: true 
      } 
     } 
    ); 

我想上傳兩個圖像文件。發佈數據/圖像產生該錯誤兩次:

未能創建上S3多部分上傳:{「消息」:「拒絕訪問 」,「堆」:「存取遭拒:訪問被拒絕\ n在 請求。 extractError (/vagrant/node_modules/aws-sdk/lib/services/s3.js:538:35)\n Request.callListeners (/vagrant/node_modules/aws-sdk/lib/sequential_executor.js:105: 20)\ n
在Request.emit (/vagrant/node_modules/aws-sdk/lib/sequential_executor.js:77:10)\n
在Request.emit (/流浪/ node_modules/AWS-SDK/LIB/request.j S:668:14)\ n在 Request.transition (在 AcceptorStateMachine.runTo (/流浪/ node_modules/aws- /vagrant/node_modules/aws-sdk/lib/request.js:22:10)\n sdk/lib/state_machine.js:14:12)\ n在 /vagrant/node_modules/aws-sdk/lib/state_machine.js:26:10\n在 請求。 (/vagrant/node_modules/aws-sdk/lib/request.js:38:9)\n在 請求。 (/vagrant/node_modules/aws-sdk/lib/request.js:670:12)\n Request.callListeners (/vagrant/node_modules/aws-sdk/lib/sequential_executor.js:115:18)「 「代碼」: 「存取遭拒」, 「區」:NULL, 「時間」: 「2016-08-24T19:43:28.415Z」, 「的requestId」: 「2802978376D53185」, 「extendedRequestId」: 「LhRlXP6H2EQo8M0ECUlL8js4W9CP99h5fvsSHjVSs3mhB9OupvWpz7UdB1HhN0Ntxf6sFLYoHdk =」,」的StatusCode 「:403,」 重試 「:假的,」 retryDelay「:44.73750370088965}

第二個是的,當然不同

我嘗試使用空options對象沒有運氣

歡迎任何形式的建議。提前致謝。

嘗試使用不同的鍵/鍵標識,結果相同。我怎樣才能得到上傳的文件的網址?當然,我可以成功上傳圖像後:p

+0

您確定您的AWS密鑰正確嗎?你可以使用郵遞員等其他客戶上傳嗎? –

+0

是的,密鑰是正確的,如果我輸入了錯誤的密鑰--->「我們計算的請求籤名與您提供的簽名不匹配,請檢查您的密鑰和簽名方法。是錯誤。 –

回答

0

嘗試啓用用戶權限s3桶(權限)策略。 您是否將角色分配給您正在運行代碼的實例? (如果使用EC2作爲你的工作站)

這應該是一個評論。但是,不幸的是,我無權發表評論。