简体   繁体   中英

How to check if File System Access API is available

I want to save a file with data input by the user on a website to the user's device using showSaveFilePicker() in Javascript (purely locally used).
This is currently not supported by all browsers, especially not on mobile devices.
I need a way to check, if the browser used is offering showSaveFilePicker() , so that I can offer a download to the standard folder if showSaveFilePicker() is not available.
How can I check for that?

Using try-catch does not work, as the error will also be thrown when the user aborts saving - which should of course not lead to a saving of the file.

I found the solution:

Check the availability with
if('showOpenFilePicker' in window){}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM