jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
3.97k stars 413 forks source link

[Q] An alternative? #285

Open AlttiRi opened 2 years ago

AlttiRi commented 2 years ago

You have added string "(legacy-ish)" and note that there is this new native way to save files.

Do you mean File System Access API?

Well... it does not allow to save files automatically, without showing the "Save as" dialogue (file picker). For me, only this issue makes this API ~a garbage~ mostly useless as an API for file saving.

I think, auto downloading (saving files without "save as" modal, that can be turns off in the browser settings) is the core thing for a dowloading API, but File System Access API does not support it. So, I would not say, that it's a real alternative.

Or maybe I missed something?

jimmywarting commented 2 years ago

Yes, i did mean File System Access.

Browser also sometimes asks for a place to save files. it's pretty much a browser settings weather or not you want to allow auto download. So it's mostly up to each and everyone, and not something you have control over.

there is an alternative option when using the File System Access api to ask for permission to write to a folder if you need to save multiple files. but that ask for more annoying prompts...

I initially thought File System Access was really cool and hoped that Safari and FF would also jump on the train. but they are only going to focus on a browser sandboxed api. So now it's devided up in

file-system-access is also heavily restricted and must follow the annoying "safe browsing" and only allow for atomic writes and not "write in place" so if you wish to append data to a file then if first have to copy that file to a temporary location, modify it, and then replace the old file. which is very costly... doe "whatwg/fs" don't have this issue, it supports non atomic writes (aka write in place)

jimmywarting commented 2 years ago

it's sad that file-system-access will not be introduced into Safari and FF 😞 hopefully they will change there mind and realize that there is a safe way to include some of what file system access provides

ivanjx commented 1 year ago

i am inspecting mega.nz with firefox and it doesnt seem that they use indexeddb to save downloaded files so i assume that they use file system api (fs), as they also use the same method with chrome/edge. the url scheme it uses is blob: at the downloads page. are you aware of this?

ivanjx commented 1 year ago

in chrome, when you download a file from mega.nz, it stores the file into filesystem api because it is encrypted end-to-end. after the whole file is downloaded, it somehow gets converted into blob: scheme. i would like to know how to build a blob from file system sandbox. thanks

image

download link from download page: blob:https://mega.nz/ffa3d140-636a-4f31-ac07-9ddd374f07bf

jimmywarting commented 1 year ago

I have no answer to that, don't really want to go into the how and what they are doing.