Code Monkey home page Code Monkey logo

Comments (36)

richardshergold avatar richardshergold commented on May 25, 2024 3

I'm seeing the same thing today in my Ionc app running on iOS 11.4.1 (and it was working fine in earlier versions of iOS)

I'm doing this:

fileTransfer.download(file, this.file.dataDirectory + 'file.' + ext)

and I see this in the console:

File Transfer Finished with response code 200

and then..

ERROR: {"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0},"line":1,"column":4972,"sourceURL":"file:///var/containers/Bundle/Application/4F128730-988B-41F2-8C34-407C1DEEEC9D/myApp.app/www/build/18.js"}

Ionic Info:

Ionic:

   ionic (Ionic CLI)  : 4.0.6 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.0, ios 4.5.5

System:

   ios-deploy : 2.0.0
   NodeJS     : v8.11.3 (/usr/local/bin/node)
   npm        : 6.3.0
   OS         : macOS High Sierra
   Xcode      : Xcode 9.4.1 Build version 9F2000

Environment:

   ANDROID_HOME : not set

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024 2

Workaround. You can place headers in the download process and use "if-Modified-Since" and set it some date in the past. I think the problem is that on iOS 11.4 file downloads appear to be called from cache causing a download success with a partial file.

This worked for us.

from cordova-plugin-file-transfer.

santhoshbabu-d avatar santhoshbabu-d commented on May 25, 2024 1

Download File is corrupted in the Android Kitkat 4.4, installed plugin today

import { FileTransfer ,FileTransferObject} from '@ionic-native/file-transfer/ngx';
import { File } from '@ionic-native/File/ngx';

constructor( private transfer: FileTransfer, private file: File,...)

download(){
let downloadUrl = encodeURI('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf');
let path = 'cdvfile://localhost/persistent/Download/';
const transfer = this.transfer.create();
transfer.download(downloadUrl, path + 'dummy.pdf').then(entry => {
let url = entry.toURL();
console.log('File url\n' + url);
}, (error) => {
// handle error
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("download error code" + error.code);
});
}

from cordova-plugin-file-transfer.

janpio avatar janpio commented on May 25, 2024

What exactly are you talking about?
What version of Cordova CLI, Cordova iOS, the plugin are you using?
What is the code that is being executed?

from cordova-plugin-file-transfer.

rachithhegde avatar rachithhegde commented on May 25, 2024

This is my code for download video file from the server for IOS version(11.4.1)

fileTransfer.download(url, this.file.dataDirectory + 'file.mp4').then((entry) => {
    console.log('download complete: ' + entry.toURL());
  }, (error) => {
    // handle error
  });

ionic version: 3.19.1
node version: 8.11.3
cordova version: 8.0.0
cordova-plugin-file-transfer version: 1.7.1
node module @ionic-native/file-transfer version: 4.11.0
platform Ios version: 4.5.5

from cordova-plugin-file-transfer.

janpio avatar janpio commented on May 25, 2024

Does it work in other iOS versions?
How are you learning that the file is corrupted?

from cordova-plugin-file-transfer.

rachithhegde avatar rachithhegde commented on May 25, 2024

In ios 10.3.0 is also it is not working. I am fetching the file list from the dataDirectory and trying to play it is not playing. File size is around 30mb, In fileTransfer.onProgress event we are getting 0 and then directly 100 and file downloaded success is showing in alert.

from cordova-plugin-file-transfer.

janpio avatar janpio commented on May 25, 2024

Does this happen all the time or just sometimes @richardshergold @rachithhegde?
You can't confirm that it also happens on iOS 10.3.0 @richardshergold (as @rachithhegde indicated in #201 (comment))?

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

@janpio sorry for the delay - I'm in the UK. it happens all the time on any type of attachment I try. I will get one of my testers to try an iOS 10 device and let you know. Apart from the change to iOS 11.4 on my device, one additional change in my own project (since this was all working) has been raising Cordova iOS from 4.5.0 to 4.5.5 - do you know if that might be connected to this issue?

from cordova-plugin-file-transfer.

janpio avatar janpio commented on May 25, 2024

(No worries about any wait time - just trying to collect all information)

raising Cordova iOS from 4.5.0 to 4.5.5 - do you know if that might be connected to this issue?

No idea, should not affect it - but it would be glorious if you could check it out and report back. Downgrading should not be too hard I hope.

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

@janpio apparently it is also affecting older versions of iOS too (my tester has just reported issues on a 10.3.2 device I think). I will see if I can look into the Cordova IOS thing later.

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

@janpio This its also not working on Android 7 so I'm starting to think this may not be an issue with your plugin at all as that seems a bit weird as it was all working before. Possibly something to do with the file plugin or the version of the @ionic-native/file wrapper. I will try and do some tests myself today and let you know if I find anything.

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

@janpio ignore that last comment. Android is working fine. I will look at the IOS issue now....

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

@janpio ok now it seems to be working for me in iOS too (iOS 11 anyway) so I'm not sure what was going on before. It certainly all seems ok now anyway :-)

from cordova-plugin-file-transfer.

janpio avatar janpio commented on May 25, 2024

So now everything ok for you again @richardshergold?

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

At the moment yes, I will report back if I have any issue.

from cordova-plugin-file-transfer.

rachithhegde avatar rachithhegde commented on May 25, 2024

for me still same issues in ios 11.4.1
@richardshergold please tell us what you did which resolves the issues.

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

@rachithhegde I haven't changed anything - I think I was mistaken into seeing the issue in the first place.

from cordova-plugin-file-transfer.

rachithhegde avatar rachithhegde commented on May 25, 2024

can you please tell us the file transfer plugin version and file transfer node module version?

$ ionic cordova plugin add cordova-plugin-file-transfer--- version?
$ npm install --save @ionic-native/file-transfer-- version?

from cordova-plugin-file-transfer.

richardshergold avatar richardshergold commented on May 25, 2024

cordova-plugin-file-transfer 1.7.1 "File Transfer"
"@ionic-native/file-transfer": "^4.11.0"

Full Ionic Info:

Ionic:

ionic (Ionic CLI) : 4.0.6 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.1.0, ios 4.5.5

System:

ios-deploy : 2.0.0
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 6.3.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000

Environment:

ANDROID_HOME : not set

from cordova-plugin-file-transfer.

rachithhegde avatar rachithhegde commented on May 25, 2024

We have tried with the above specified platform version still the problem is not resolved.

cap

we are look for the solution like the attached image.

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024

Can confirm that downloads are not working on big sizes (15mb and above) in iOS 11.4. This was working in older versions of iOS

from cordova-plugin-file-transfer.

ninexus avatar ninexus commented on May 25, 2024

we have also same problem, trying to download the pdf file , it get downloaded 0 byte making it corrupt. , @BrainstemStudio how the header to be added can you suggest some example will be helpful

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024

@ninexus read the docs here https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/#download

Example:

/**
 * Download a file example
 * Accepts the parameters: source, target, successCallback, errorCallback, trustAllHosts and options.
 * Options can contain headers as shown below.
 * 
 * source          : The file to download, make sure to "encodeURI"
 * target          : where to save the file locally, use cordova.file for root. See https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/
 * successCallback : function to run once the file has downloaded. Passes entry.
 * errorCallback   : function to run if there is an error. Passes error
 * trustAllHosts   : Must be false for production.
 * options         : Support for headers. Authorization or cache control.
 */
var fileTransfer = new FileTransfer();

fileTransfer.download(
    encodeURI('http://some.server.com/picture.png'),
    cordova.file.dataDirectory+'your-folder/picture.png',
    function(entry) {},
    function(error) {},
    false,
    {
        headers: {
            "if-Modified-Since" : "Wed, 21 Oct 2015 07:28:00 GMT"
        }
    }
);

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024

@ninexus Also read https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html as you will notice cordova has deprecated this plugin in favor of standards.

But the if-Modified-Since fix should resolve the issue as it did for us.

from cordova-plugin-file-transfer.

ninexus avatar ninexus commented on May 25, 2024

@BrainstemStudio thanks for the suggestion we tried the given suggested code its still download 0 byte pdf file, please take a look if there is anything you can recommend in it.

ft.download(encodeURI(WC_API.pdf_file_server +'/'+ parsha_id), 'cdvfile://localhost/persistent/.systems/caches/data/file/file_'+parsha_id+'.pdf',function(entry) {
console.log("download complete: " + entry.toURL());
$scope.pdfurl = entry.toURL();
$ionicLoading.hide();
PDFFileService.updateData({
is_downloaded: 1,
source: entry.toURL(),
parsha_id: parsha_id
});
console.log($scope.pdfurl);
openPdfDoc($scope.pdfurl, $scope.parsha_name);
},
function(error) {
console.log(error);
$ionicLoading.hide();
alert('Failed opening pdf, server error.');
}, false,
{
headers: {
"if-Modified-Since" : "Wed, 21 Oct 2015 07:28:00 GMT"
}
});

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024

@ninexus I would suggest checking console errors and debug any network issues. Also you may want to use "onprogress" method for downloads and check whats happening as it downloads.

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/#properties

e.g

ft.onprogress = function(e) {
    if (e.lengthComputable){
        var percent = (e.loaded / e.total) * 100;
        console.log(percent+'% downloaded');
        console.log(e);
    }
    else{
        console.log(e);
    }
}

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024

@santhoshbabu-d For some reason android 4.4 below doesn't play well with https connections when downloading files. We ran into a similar issue and had to use http when android 4.4 was detected.

from cordova-plugin-file-transfer.

santhoshbabu-d avatar santhoshbabu-d commented on May 25, 2024

its downloading but file corrupted

from cordova-plugin-file-transfer.

santhoshbabu-d avatar santhoshbabu-d commented on May 25, 2024

from what version this plugin support

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024

@santhoshbabu-d try the "if-Modified-Since" header fix described above

from cordova-plugin-file-transfer.

santhoshbabu-d avatar santhoshbabu-d commented on May 25, 2024

tried the download from http showing same issue,file corrupted,

Also showing erro when adding header in fileTransfer (Ionic 4.12.0)
error TS2554: Expected 0-2 arguments, but got 4.

from cordova-plugin-file-transfer.

BrainstemStudio avatar BrainstemStudio commented on May 25, 2024

@santhoshbabu-d I don't think the plugin is at fault and this is likely to do with the connection to the file you are trying to download. When inspecting the headers of the file you are trying to download i see a few modern headers such as "strict-transport-security" which may causes issues in lower versions of android devices. My suggestion is to try the following:

  1. Test with a file on your own server or from a localhost environment.
  2. Use a android version detection and downgrade the connection to http for < 4.4 (when downloading files). You can do this with "navigator.userAgent".
  3. Use https://www.ssllabs.com/ssltest/ to test server settings. There has been lots of changes to secure connections which will cause problems on old devices more specifically ones that only support TSL 1.0
  4. Test with a modern device or os version.

FYI Cordova is unlikely to update this plugin in favor of standards.
Source: https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html.

from cordova-plugin-file-transfer.

santhoshbabu-d avatar santhoshbabu-d commented on May 25, 2024

Checked with the Android 5.0.2 issue looks same

from cordova-plugin-file-transfer.

santhoshbabu-d avatar santhoshbabu-d commented on May 25, 2024

Thanks for the help, finally it work after update ionic

from cordova-plugin-file-transfer.

timbru31 avatar timbru31 commented on May 25, 2024

I'm closing this issue since it's stale and sounded like a potential bug in iOS 11.4.1 with some workarounds.

If the issue persists, please create a new one, follow the template and most importantly create a minimum reproducible example.

from cordova-plugin-file-transfer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.