Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to be able to work with the library in the browser #1

Open
trigoesrodrigo opened this issue Jan 8, 2015 · 5 comments
Open

Comments

@trigoesrodrigo
Copy link

I'm developing a Cordova application and wanted to be able to debug it without a device (using the browser platform). I finally managed to get it working but had to perform several steps:

  1. I had to force the isCordova check to false in order to be able to work with the library. Otherwise I received the following error (Could not get Cordova FileSystem: FileError {code: "Missing Command Error"})

  2. I also needed to explicitly request file quota to be able to work with persistent storage. I did it by executing webkitStorageInfo.requestQuota(webkitStorageInfo.PERSISTENT, options.storageSize); after the fs initialization.

  3. In order to be able to correctly save downloaded binary files I had to set the respose type of the xhr fnction to blob (xhr.responseType='blob';) and write(file,xhr.response).then(win,fail);. In my tests it worked for every file type, but it could be changed to work with text, array, etc, depending on the options passed to the download function.

  4. Finally, I had to launch chrome with the flags --disable-web-security --allow-file-access-from-files --user-data-dir=datadir and manually allow file storage in the browser

I think it would be great to be able to configure the behaviour for the items 1,2,3 in the options of CordovaPromiseFS.

In any case, many thanks as cordova-promise-fs it is a wonderful library :)

@markmarijnissen
Copy link
Owner

Cool! Thanks for creating this issue.

Can you provide a code snippet for 2? (i.e. update this fiddle)

@trigoesrodrigo
Copy link
Author

I left an example at https://github.com/trigoesrodrigo/cordova-promise-fs-browser-test

Just cordova add platform browser

If you launch chrome with file:///absolute/path/to/platforms/browser/www/index.html --disable-web-security --allow-file-access-from-files you will see that the browser requests access to store files, and then the fs.write works. If you go back one commit, you'll see that fs.write fails.

@markmarijnissen
Copy link
Owner

just an update - i am busy doing other (paid) work and not sure when I will come around to fix this. At best, end of this week. At worst, in a few weeks.

@markmarijnissen
Copy link
Owner

Hi - it's already March now and I'm too busy for feature requests. If you can submit a PR, I'll merge, but otherwise, this will have to wait until I have more time.

@trigoesrodrigo
Copy link
Author

My apologies for the late response, I was out of the country and didn't
have access to the Internet.

Right now I'm quite busy in another project and unfortunately I won't have
time for a few weeks to prepare a proper PR.

Again, I wanted to thank you for your wonderful work with the library, it
saved me a lot of time fiddling with the wonky file system api :)

Best regards.
Rodrigo.

On 17 March 2015 at 20:24, Mark Marijnissen notifications@github.com
wrote:

Hi - it's already March now and I'm too busy for feature requests. If you
can submit a PR, I'll merge, but otherwise, this will have to wait until I
have more time.


Reply to this email directly or view it on GitHub
#1 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants