Filesaver.js: Q: Can I use the "SaveAs" function in FileSaverJS?

Created on 16 Aug 2019  路  5Comments  路  Source: eligrey/FileSaver.js

The SaveAs function currently provided by FileSaverJS seems to save a file by clicking and closing the anchor element without bringing up the "SaveAs" window.

I want to open a "SaveAs" window via FileSaverJS and save the file to the desired desktop path.

Is this possible?

question

Most helpful comment

For the file name problem, this is tracked as https://github.com/WICG/native-file-system/issues/80, filed by the very @jimmywarting :-)

Are there plans on adding Native File System API support to this library? We (Google) offer a library that can do this (https://github.com/GoogleChromeLabs/browser-nativefs), but @jimmywarting also has developed something similar (https://github.com/jimmywarting/native-file-system-adapter). Either way, I'd be happy to help.

All 5 comments

it's a browser preferences whether or not it should automatically save and download or if it should ask you where it should save the file

chrome https://lifehacker.com/make-chrome-ask-where-to-save-downloaded-files-by-chang-1790840372

firefox https://support.mozilla.org/en-US/kb/change-firefox-behavior-when-open-file

safari https://apple.stackexchange.com/questions/264594/prevent-safari-10-x-from-auto-downloading-files

edge https://www.windowscentral.com/how-change-download-options-edge-windows-10

Internet explorer: DO NOT USE IT ANY MORE!

anything else: google it

@jimmywarting
Thank you for answer.

But what I'm curious about is whether there's a way to fix it with code, not browser settings.

Can I use features like "document.execCommand ('SaveAs')" with FileSaverJS?

erm, no there is no such javascript solution (yet).

i did experiment with native filesystem api (https://github.com/WICG/native-file-system/blob/master/EXPLAINER.md)

I played with it a bit in chrome canary. After enabling a flag for it
when trying it out聽then i where able to ask for a destination where i should write a file

chooseFileSystemEntries({ type:'saveFile' })

then you get back a fileHandler (after the user has decided what it should be named and where to save). then you should write the blob/chunk/stream too it (asynchronous)

image

unfortunately there where no way to suggest a filename, so the user don't know what they are saving, so they don't know what the extension should be, so the alternetive is to use type openDirectory with write permission and then write the file to wherever you want

I have a default setting which opens the save as dialogue in Firefox.
I wonder if I could change the from to something meaningful:

Screenshot 2019-11-05 at 18 18 43

Is there a setting I could change this?

For the file name problem, this is tracked as https://github.com/WICG/native-file-system/issues/80, filed by the very @jimmywarting :-)

Are there plans on adding Native File System API support to this library? We (Google) offer a library that can do this (https://github.com/GoogleChromeLabs/browser-nativefs), but @jimmywarting also has developed something similar (https://github.com/jimmywarting/native-file-system-adapter). Either way, I'd be happy to help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Toterbiber picture Toterbiber  路  5Comments

MFEKN picture MFEKN  路  5Comments

josepoma picture josepoma  路  4Comments

meenucoditas picture meenucoditas  路  6Comments

CSchulz picture CSchulz  路  4Comments