I am trying to upload image from ionic application to S3 using presigned URL.
This is the current situation:
Ionic application sends request to server to get presigned upload URL from AWS S3.
On server side I have a node application that is using aws-sdk to get presigned URL and then returns it back to client.
This is my code on Ionic side that should upload file to AWS
var options = {
fileKey: 'file',
fileName: fileName,
mimeType: 'image/jpeg',
chunkedMode: false,
timeout: 300000,
httpMethod:'PUT',
encodeURI: false,
headers: {
'Content-Type': 'image/jpeg'
}
};
var ft = new FileTransfer();
ft.upload(cordova.file.dataDirectory + fileName, uploadLink, function () {
console.log("image uploaded");
}, function (err) {
console.log(err);
}, options);
This code works on iOS device, but when I deploy application to Android and try to upload file it fails with the following error:
FileTransferError body: null code:3 exception: "Write error: ssl=0x8ec63f80: I/O error during system call, Connection reset by peer" http_status: null source: "file:///data/user/0/com.ionicframework.xxxxxxxx/files/xxxxx.jpg" target: "https://xxxxxx.s3.eu-central- ..... "
Ionic info Cordova CLI: 6.4.0 Ionic CLI Version: 2.1.12 Ionic App Lib Version: 2.1.7
Android version on device is 6.0
I am a bit confused as it is work on iOS but it doesn't work on android. I have used cordova file transfer before and have never run into similar situation. However this is the first time that I am uploading files from android to S3 directly.
Any help would be highly appreciated.