Giter VIP home page Giter VIP logo

cordova-file-cache's People

Contributors

chrisvasz avatar colinfindlay-nz avatar markmarijnissen avatar starquake avatar xontab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cordova-file-cache's Issues

Uncaught (in promise) FileError {code: 12}

I got this plugin working for iOS and everything works great. Thanks!

I then went over to the android side, and I'm getting this javascript error when the app loads:

Uncaught (in promise) FileError {code: 12}

...no backtrace - that's really it.

The changes I made to cordova.xml were simply adding this:

<plugin name="cordova-plugin-file" spec="~4.1.1" />
<plugin name="cordova-plugin-file-transfer" spec="~1.5.0" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />

JS libs added:

<script type="text/javascript" src="js/lib/CordovaPromiseFS.js" defer></script>
<script type="text/javascript" src="js/lib/CordovaFileCache.js" defer></script>

Initializing the cache like so:

new CordovaFileCache({
    fs: new CordovaPromiseFS({Promise: Promise}),
    serverRoot: $server_hostname + '/assets/',
    localRoot: 'data',
    cacheBuster: false
  })

...again, this all works perfectly on iOS, so this must be some concern of Android...? Any help would be appreciated. Thank you!

Performance issues

Everything seems to be 'working; properly, with this script. However, I am noticing a ~100 ms time needed to load individual files from cache. Is there any way to speed up this process?

Thanks in advance,

GS

Add Auth Header

Is it possible to add an auth header to the download request?

.download()

Uncaught (in promise) ["http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-95691.jpg"]

Duplicate progressEvent fired for last item in queue

Because the onprogress event gets fired for every downloaded file, AND again just 4 lines later, the last item gets a progress event twice. No need for this second one; I would remove it.

in the onDone inner function in FileCache.download, after

self.list().then(function(){ 
    // final progress event!
    if(onSingleDownloadProgress) onSingleDownloadProgress(new ProgressEvent());

    // etc...
}

Wrong extension when contains number

The regex only matches alpha characters. For extensions such as mp4, this results in "mp". The regex should be changed from:

var ext = url.match(/.[a-z]{1,}/g);

to

var ext = url.match(/.[a-z0-9]{1,}/g);

Other non-alphanumeric values may also be valid..

A promise was rejected with a non-error

It seems that cordova-file-cache is rejecting promises with non-error objects. This causes bluebird to print warnings, and it seems to totally mess up the stack trace, which is really really unhelpful.

For example, in one instance it rejects with a list of failed files or something:

reject(self.getDownloadQueue());

Please can this be fixed?

Thanks.

Error on init

Hi,

thanks for your lib. Looks very promising.
I have a problem on init and don't know how to solve it:

TypeError: undefined is not an object (evaluating 'options.Promise')
CrodovaPromiseFS.js line 90.

What I'm doing wrong?

        /* Cache */
        var cache = CordovaFileCache({
          fs: CordovaPromiseFS(),
          mode: 'hash', // or 'mirror'
          localRoot: 'data',
          cacheBuster: false 
        });

        cache.ready.then(function(list){
            // Promise when cache is ready.
            // Returns a list of paths on the FileSystem that are cached.
            console.log('cache is ready');
            console.log(list);
        });

This is what I'm calling

File saved with wrong extension if there's a query string in the URL

In hash mode, caching a Vimeo video with an access token results in a .txt file instead of a .mp4 file. This is with a URL like (for example): https://player.vimeo.com/external/#####.sd.mp4?s=12345abcdef&profile_id=###

The video itself looks like it's saved perfectly fine. Pulling it from a simulator and renaming it from #####.txt to #####.mp4 results in a video file that plays without problems. The problem is only with the wrong file name, since this messes with other plugin usage (for example, supplying the file:// URL to cordova-plugin-streaming-media).

It looks like the problem is that the plugin is just categorically replacing extensions with .txt if there's a query string in the URL. I've made a pull request, #17, that fixes the problem.

License hidden

Hi,

First of all, awesome plugin. I'm really excited to use it.

I had to do some hunting before discovering the license in the bower and npm files, which list the license as MIT. Assuming that's your intended license, GitHub advises "to avoid any potential ambiguity, it's best to include the license file with your project as well." Seeing it spelled-out would make me feel a little more comfortable.

(I believe this applies for cordova-promise-fs as well.)

Best,
Chris

Not able to cache files from PHP link

i noted that he dont download, im using PHP

Headers example

header('Cache-Control: private');
header('Content-Transfer-Encoding: binary');
header('Content-Type: audio/mpeg');
header('Content-Disposition: attachment; filename=a.mp3);
header('Content-Length: 42535355);

differing permission handling

I've noticed on oldish HTC One, this statement (in the README) is true:

The plugin requests user permission to use persistent storage at the application first start.

On a newer Nexus, the app doesn't prompt for it at load time, and it doesn't even prompt for it the first time it's used. Further, even after denying the permission, methods from CordovaFileCache.js still seem to work -- download/get/ready/toURL/clear all fine.

So, what exactly is the file permission doing? Is there any way to entirely avoid it?

Removing broken links, promise never resolves

Here's my example:

cache.add('http://google.com/404.json')
cache.download(()=> {}).then(() => {}, (failedUrls) => { console.log('failedUrls', failedUrls) })
// cache.remove('http://google.com/404.json') // <-- this works
cache.remove('http://google.com/404.json').then(() => {console.log('success')}, () => {console.log('failure')})

Neither success nor failure gets logged. My guess from looking at this is that the filesystem promise never resolves / rejects if the file does not exist. Come to think of it, maybe the bug report belongs there?

Extension matching not working for extensions with numbers (e.g. 'mp4')

The change in 'toPath' from:

var ext = url.substr(url.lastIndexOf('.')); 

to

var ext = url.match(/\.[a-z]{1,}/g);

means that extensions with numbers in them (e.g. 'mp4') are not matched properly.

I don't know what the change was made for, but perhaps this would work instead:

var ext = url.match(/\.[a-z,0-9]{1,}/g);

What events are streamed from cache.download()?

Firstly, thanks for an awesome plugin. It came highly recommended and seems to be precisely what we're looking for.

I'm wondering if there are docs somewhere about what type of events the onprogress callback gets passed?

Specifically, I'm thinking about how to implement a "ready" event for each file. Ideally I'd like to throw some files at the cache, and then trigger a callback when those files have been successfully fetched. My first thought was to try listening to the progress events and then reacting appropriately. Does that approach make sense?

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.