chrisben / imgcache.js

JS library based on the File API to cache images for offline recovery (target: cordova/phonegap & chrome)
Other
826 stars 216 forks source link

replace deprecated cordova-plugin-file-transfer #225

Open menelike opened 6 years ago

menelike commented 6 years ago

As stated on https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html cordova-plugin-file-transfer has been deprecated. This project shouldn't rely on that plugin as it will cut your project off from further cordova updates.

Binary types in JavaScript, as well as the extended XHR features, are available on the following Cordova-supported platforms without requiring any additional plugins:

Android 4.4 or newer.
iOS 10 or newer.
Windows UWP (8.1, 10 or newer all work).
Windows Phone 8 or newer.
As always, check caniuse.com for detailed support for the required bits, like Blob, Typed Arrays, and extended XHR features.

Since the recommended migration path would cut off older platform versions a major version upgrade might be appropriate.

chrisben commented 6 years ago

Thanks for the info.

If you stop including the file transfer plugin and replace the FileTransferWrapper function with this one, would it work for you?

  Private.FileTransferWrapper = function (filesystem) {
    if (Helpers.isCordova() && typeof FileTransfer !== 'undefined') {
      console.log('Old cordova-plugin-file-transfer behaviour, please consider not including it anymore');
      this.fileTransfer = new FileTransfer();
    }
    this.filesystem = filesystem;    // only useful for XHR2
};
tiparrish commented 5 years ago

Thanks for sharing. But can you provide guidance on how to place this in a file. I am getting the following error and now I'm missing something. "Uncaught ReferenceError: Private is not defined" Been trying to get a Phonegap HTML5 app to get access to android device storage. With no success!

souly1 commented 3 years ago

@chrisben , I've tested it and seems working for both iOS & Android!

Thanks!