Reputation: 686
I am trying to upload a file with ionic 2 and the cordova-file-transfer. But my server keeps returning an error that content length is missing. How can I add this to my upload headers?
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();
})
Upvotes: 0
Views: 523
Reputation: 26
chunkedMode: true,
change to chunkedMode: false,
I am working with android, uploaded to azure blob.
Upvotes: 1