Unable to upload large PDF files using file transfer plugin in ionic 4

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' });

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 => {
    console.log("Retrieved data = "+data);
  }, err => {
    console.log("Error occured = "+reject);