2016-09-29 139 views
1

我上傳圖片從fileURI所亞馬遜下面這個非常簡單的方法科爾多瓦文件傳輸到S3 AWS返回501錯誤

window.resolveLocalFileSystemURI(fileURI, function(fileEntry) { 
     fileEntry.file(function(fileObj) { 
      console.log("Size = " + fileObj.size); 

      var options = new FileUploadOptions(); 
      options.chunkedMode = false; 
      options.httpMethod = 'PUT'; 
      options.headers = { 
      'Content-Type': 'image/jpeg', 
      'Content-Length' : fileObj.size 
      }; 

      var ft = new FileTransfer(); 
      constructSignedUrl(picname, 'put').then(function (url) { 
      console.log(url) 
      ft.upload(fileURI, url, 
       function (res) { 
       deferred.resolve(); 
       }, 
       function (error) { 
       deferred.reject(); 
       }, 
       options); 
      }); 
     }); 
     }); 

的constructSignedUrl(picname,「放」)是構建presigned網址的方法。這是工作,我測試的是細跟郵遞員

服務器返回該錯誤

Message>A header you provided implies functionality that is not implemented</Message><Header>Transfer-Encoding</Header> 

好像上傳文件傳輸將報頭,我不能得到擺脫它,我該如何解決這個問題?

UPDATE:在檢查上查爾斯代理負載我看到的標題

Transfer-Encoding chunked 

仍然存在,如何可以覆蓋它。我已經將分塊模式設置爲假。

+1

' '內容長度':「0''?你在告訴S3你正在上傳一個空文件? –

+0

我重新修改並重新測試了內容長度爲文件大小的函數。但仍然得到相同的錯誤 –

+0

是否有必要明確設置Content-Length? –

回答