I am getting timeout error while uploading large PDF files with help of Cordova File Transfer plugin in IOS but in Android it’s working fine.
I am getting error as below:
FileTransferError {
body = “”;
code = 3;
“http_status” = 0;
source = “/private/var/mobile/Containers/Data/Application/A2168459-B3ED-4329-BDFE-F2B68E00B937/tmp/com.vghybrid.snfreferral-Inbox/Scan_Test_-_39_pages_test-1-1.pdf”;
target = “https://snfscan.com/customapi/api.php”;
}
I have tried adding ‘Connection: “close”’ to header & ‘chunkedMode: false’ but nothing worked.
Can anyone help me to get out of this issue I am struggling with this from last few days.
I would suggest simply using Angular’s HttpClient
for this. The file-transfer plugin was sunsetted years ago and should be left to rest in peace.
1 Like
I have tried HttpClient but I am not able to upload any file now I think that using this the file url is not passing to server using Blob.
Here is my code:
let headers = new HttpHeaders();
headers.append(‘Access-Control-Allow-Origin’, ‘*’);
headers.append(‘Access-Control-Allow-Credentials’, ‘true’);
headers.append( ‘content-type’, ‘multipart/form-data’);
headers.append(‘Accept’, ‘application/pdf’)
return new Promise((resolve,reject) => {
let formData = new FormData();
var blob = new Blob([originalFileURL], { type: 'application/pdf' });
formData.append('uploadedFile',blob);
console.log("Form Data = "+formData.getAll('uploadedFile'));
this.http.post("https://snfscan.com/customapi/api.php?action=uploadPDF"+"&tId="+tokenId+"&userId=104&uploadedFile="+originalFileURL,formData, {
headers: headers
}
).subscribe(data => {
resolve(data);
console.log("Retrieved data = "+data);
}, err => {
console.log("Error occured = "+reject);
});
});
Hi @deepanshu0622 ! I realize this was several years ago, but I am facing the same problem and was wondering if you were able to find a solution. If so, I’d love to hear how you did it.
Thanks,
Josh
I wanted to say, I found a solution to my problem. This article helped a lot (Making Fetch Happen: Replacing Native Plugins with Web APIs - Ionic Blog), was extremely helpful in allowing fetch to be used to grab the file and get the blob. From there, I was able to use the azure javascript sdk for uploading the blob in chunks. Still doing some more testing now, but I wanted to mention this article in case it helps anyone else