cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse <purplecabb...@gmail.com>
Subject Re: should FileTransfer.download() auto mkdir target's path?
Date Wed, 16 Apr 2014 19:43:03 GMT
Can't find the original issue, but it was specific to file and not
file-transfer...

>From the File Spec [1] ( which is somewhat inherited by the File transfer
plugin )

+ It is an error to attempt to create a directory whose immediate parent
does not yet exist.
+ It is an error to attempt to create a file whose immediate parent does
not yet exist.

Whether we view the file-transfer plugin as a high level helper that hides
these details, or as a strict extension to the File plugin is up for
discussion.


[1] http://www.w3.org/TR/2011/WD-file-system-api-20110419/

@purplecabbage
risingj.com


On Wed, Apr 16, 2014 at 12:32 PM, Jesse <purplecabbage@gmail.com> wrote:

> Originally WP8 was creating any missing intermediate folders, but this was
> raised as a defect because the spec explicitly states it should produce an
> error in this case.
> Trying to dig up the issue ...
>
>
> @purplecabbage
> risingj.com
>
>
> On Wed, Apr 16, 2014 at 12:07 PM, James Jong <wjamesjong@gmail.com> wrote:
>
>> I think iOS attempts to create the directory first.
>>
>> https://github.com/apache/cordova-plugin-file-transfer/blob/master/src/ios/CDVFileTransfer.m#L660
>> -James Jong
>>
>> On Apr 16, 2014, at 2:58 PM, Shazron <shazron@gmail.com> wrote:
>>
>> > Additional info:
>> > iOS will not create intermediate folders for download(), they must
>> already
>> > exist
>> > (based on my tests with NSFileManager
>> createFileAtPath:contents:attributes
>> > call that is used by FileTransfer.download())
>> >
>> >
>> > On Wed, Apr 16, 2014 at 10:57 AM, Mike Billau <mike.billau@gmail.com>
>> wrote:
>> >
>> >> Hello,
>> >>
>> >> When using FileTransfer.download(), if the target location contains
>> folders
>> >> that do not exist on the device, should FileTransfer auto-magically
>> mkdir
>> >> these folders to save the download?
>> >>
>> >> If target= /foo/image.png, and if /foo/ doesn't exist, Android will
>> create
>> >> the /foo/ dir for you. WP8 doesn't seem to do this and will instead
>> return
>> >> with an error. I don't know which implementation should be considered
>> >> "correct." It seems like a "good" dev should first check that the
>> target
>> >> exists and create it before saving the image, but I'm all for making
>> things
>> >> easier for the developer and just doing it auto-magically (I hate that
>> >> word...)
>> >>
>> >> I'm using 3.1 btw, sigh and sorry! Thanks everyone for your opinions.
>> >>
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message