Deleting a File object in the HTML5 FileSystem API problem.

831 views
Skip to first unread message

Demetrios Papadopoulos

unread,
Feb 9, 2012, 10:17:43 PM2/9/12
to Chromium-dev
Chromites,

I found out today that it is not possible to delete a File object,
just by having a reference to it.
To delete a File a FileEntry object (for calling fileEntry.remove()).
To get a FileEntry corresponding to a File object the full or relative
path of the File is needed in order to call fs.root.getFile() or
parentDir.getFile() respectively. The only way to get that path is the
attribute webkitRelativePath of the File class.

Unfortunately there seems to be a bug in Webkit that leaves
webkitRelativePath empty when copying a file. In other words only
files provided from a <input> element have this attribute populated,
copying those files to a persistent local storage results in empty
webkitRelativePath. I believe this is related with bug
http://code.google.com/p/chromium/issues/detail?id=97585.

Am I missing something? Any workarounds or suggestions are
appreciated. Also if you know the right people to forward this bug
please do so.

Thank you
dpapad

Eric Uhrhane

unread,
Feb 13, 2012, 12:32:28 PM2/13/12
to dpa...@chromium.org, Chromium-dev
I'm not really sure what you're trying to do.
A File is a Blob, and both are immutable. If you want to delete a
file on disk...where is this file? Is it in the user's FileSystem API
sandbox? If it's not, why do you think you should have the ability to
delete it?

Is this on ChromeOS, using the FileBrowser extension? Is it in regular Chrome?

You mention problems getting information on its path after copying it.
But you know where you've copied it to, so perhaps you're trying to
delete the source file? That's not something we permit in Chrome, but
I'd have to check on ChromeOS.

Eric

> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
>    http://groups.google.com/a/chromium.org/group/chromium-dev

Demetrios Papadopoulos

unread,
Feb 13, 2012, 12:55:04 PM2/13/12
to Eric Uhrhane, Chromium-dev
I am talking about deleting a file from the sandboxed filesystem that
is allocated to the website, just by having a reference to the File
object. The example I tried is the following
1) copy a file from the disk to the sandbox filesystem (say to
/hello/world.txt). Now forget about the original file on disk.
2) Try to delete /hello/world.txt (not having a FileEntry reference,
just having a File reference). There is no way of knowing where the
file is located since webkitRelativePath is empty. As far as I
understand it should be populated with '/hello/world.txt'. I don't
know where I copied to (unless i do some workaround like creating a
wrapper class around the File class and populate webkitRelativePath
myself).
This is happening in Chrome and has nothing to do with the FileBrowser
extension.
Reply all
Reply to author
Forward
0 new messages