You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Andrew Grieve <ag...@chromium.org> on 2014/07/03 03:20:10 UTC

Re: Questions about FileSystem documentation and paths

Thanks for putting together this blog post Ray!

Assume this is addressed in
https://github.com/apache/cordova-plugin-file/pull/59? (Which is an awesome
change! Thanks Kerri!)

As a nit: you can simplify your code a bit by skipping the .getFile() call:
resolveLocalFileSystemURL(cordova.file.dataDirectory + fileName, appStart,
downloadAsset)




On Sun, Jun 29, 2014 at 1:04 PM, Ray Camden <ra...@adobe.com> wrote:

> Hey folks - I originally raised this on the Google Group as I assumed it
> was just an issue w/ my code, but I believe this is a documentation issue
> so I'm raising it here. If wrong, let me know. :)
>
> I'm working on a set of of demos related to the FileSystem feature to
> answer a series of FAQs risen on my blog. For my first sample app, I wanted
> to build something simple:
>
> Check for a file on the device.
> If not there, fetch it.
>
> Looking at the docs for the FileSystem important dirs, I assumed that
> cordova.file.applicationStorageDirectory made the most sense. The docs say
> it is: "Root of app's private writable storage."
>
> Note the words private and writable. In my mind that was: "I can write to
> it and it is private, no other app can use it."
>
> But in my testing when I tried to FileTransfer crap down to it, I always
> got this error:  "Could not create target file"
>
> Not really sure what to do, I eventually tried cordova.file.dataDirectory.
> According to the docs for it, it is: "Where to put app-specific data
> files." Since it didn't say Private, my understanding was: "Ok, I can put
> crap here too, but it is public, so other apps can see it."
>
> Switching to this made my app work immediately. (Haven't tested Android
> yet.)
>
> So my question is - did I simply misunderstand the documentation for
> applicationStorageDirectory? If so, if someone can help explain what I did
> wrong, I'll happily write it up in a PR to improve the doc.
>
> If I didn't misunderstand it and there is a bug, I'll file a report.
>
> If you want to see the entire app (again, it is incredibly simple), you
> can see it here:
> https://github.com/cfjedimaster/Cordova-Examples/tree/master/checkanddownload/www

RE: Questions about FileSystem documentation and paths

Posted by Ray Camden <ra...@adobe.com>.
If you want to move this to comments on the blog entry, that would be cool. 

Can you explain a bit more? I'm not seeing which step ....

Oh... so resolveLocalFileSystemURL will call the second argument on success and the third on failure. 

Yeah - that's significant enough for me to rewrite the sample and blog post.
________________________________________
From: agrieve@google.com <ag...@google.com> on behalf of Andrew Grieve <ag...@chromium.org>
Sent: Wednesday, July 02, 2014 8:20 PM
To: dev
Subject: Re: Questions about FileSystem documentation and paths

Thanks for putting together this blog post Ray!

Assume this is addressed in
https://github.com/apache/cordova-plugin-file/pull/59? (Which is an awesome
change! Thanks Kerri!)

As a nit: you can simplify your code a bit by skipping the .getFile() call:
resolveLocalFileSystemURL(cordova.file.dataDirectory + fileName, appStart,
downloadAsset)




On Sun, Jun 29, 2014 at 1:04 PM, Ray Camden <ra...@adobe.com> wrote:

> Hey folks - I originally raised this on the Google Group as I assumed it
> was just an issue w/ my code, but I believe this is a documentation issue
> so I'm raising it here. If wrong, let me know. :)
>
> I'm working on a set of of demos related to the FileSystem feature to
> answer a series of FAQs risen on my blog. For my first sample app, I wanted
> to build something simple:
>
> Check for a file on the device.
> If not there, fetch it.
>
> Looking at the docs for the FileSystem important dirs, I assumed that
> cordova.file.applicationStorageDirectory made the most sense. The docs say
> it is: "Root of app's private writable storage."
>
> Note the words private and writable. In my mind that was: "I can write to
> it and it is private, no other app can use it."
>
> But in my testing when I tried to FileTransfer crap down to it, I always
> got this error:  "Could not create target file"
>
> Not really sure what to do, I eventually tried cordova.file.dataDirectory.
> According to the docs for it, it is: "Where to put app-specific data
> files." Since it didn't say Private, my understanding was: "Ok, I can put
> crap here too, but it is public, so other apps can see it."
>
> Switching to this made my app work immediately. (Haven't tested Android
> yet.)
>
> So my question is - did I simply misunderstand the documentation for
> applicationStorageDirectory? If so, if someone can help explain what I did
> wrong, I'll happily write it up in a PR to improve the doc.
>
> If I didn't misunderstand it and there is a bug, I'll file a report.
>
> If you want to see the entire app (again, it is incredibly simple), you
> can see it here:
> https://github.com/cfjedimaster/Cordova-Examples/tree/master/checkanddownload/www