whatwg / fs

File System Standard
https://fs.spec.whatwg.org/
Other
235 stars 19 forks source link

Add a FileSystemFileHandle copy method #159

Open johot opened 9 months ago

johot commented 9 months ago

What problem are you trying to solve?

I am currently building a web based image editor/viewer. The user should be able to copy photos / files in the editor.

The problem I am having right now is that there is no copymethod I can find in the file system api. There are functions like remove and move which work in Chrome but no copy method.

I can currently create a copy of a file by basically creating an empty file and copying the content of the original file however this destroys the files last modified metadata. When it comes to photos especially that have no EXIF metadata destroying the last modified date metadata can be very unfortunate.

Is there any plans on supporting a copy method that retains the last modified time? Thank you for your awesome work :D

What solutions exist today?

You can create a new file and copy content from original -> new by using createWritable but this destroys metadata. For FileSystemHandle there is a move method that doesn't destroy the metadata but in my case I don't want to affect the original file.

How would you solve it?

Add a copy method to FileSystemHandle or at least to FileSystemFileHandle that copies a file just like in the underlying OS preserving the last modified date.

Anything else?

No response