2017-04-25 50 views
0

我想上傳一個文件離子2和cordova文件傳輸。但我的服務器不斷返回內容長度丟失的錯誤。我怎樣才能把這個添加到我的上傳頭文件中?離子2文件傳輸不添加內容長度

let options: FileUploadOptions = { 
      fileKey: 'file', 
      fileName: fileName, 
      httpMethod: "PUT", 
      mimeType: 'image/jpeg', 
      chunkedMode: true, 
      headers: { 
       'x-ms-blob-type': 'BlockBlob', 
       'Content-Type': 'image/jpeg' 
      } 
     } 
     this.fileTransfer.upload(filePath, submitUri, options, true) 
      .then((data) => { 
       debugger; 
       this.loading.dismiss(); 
       let alert = this.alertCtrl.create({ 
        title: 'Upload Success', 
        subTitle: 'Your image has successfully been uploaded.', 
        buttons: ['Dismiss'] 
       }); 
       alert.present(); 
      }, (err) => { 
       this.loading.dismiss(); 
       debugger; 
       let alert = this.alertCtrl.create({ 
        title: 'Upload Error', 
        subTitle: 'An error occured while uploading your image. Please try again.', 
        buttons: ['Dismiss'] 
       }); 
       alert.present(); 
      }) 
+0

你可以添加你的代碼嗎?你使用的是哪個版本的插件?在哪個平臺上測試(Android,iOS)? – e666

+0

添加我的代碼並使用1.6.2並在android上進行測試。 –

回答

1

chunkedMode: true,變化chunkedMode: false,

我與Android平臺,上傳到蔚藍的團塊。