简体   繁体   中英

File System Access API open file with local default application

In a web application I am working on I would like to be able to download files, modify them localy and reupload them to the server.
To make it as easy as possible for the users, I would like them to choose the download location and use a single button to upload the changes afterwards.
My current apporach is the following:

  1. Use window.showSaveFilePicker to choose location and get a FileSystemFileHandle
  2. Download the content and write it to the FileSystemFileHandle
  3. Show a button which allows to upload the changes using FileSystemFileHandle#getFile to get the modified content.

This approach works pretty well but the user has to manually search and open the file after the download and I would like to support them in this step and make it as simple as possible.
Ideally the file should automatically be opened with the default application after the download but I couldn't find a way to do that.
One idea was to open the file in a new tab using the file:// -URL, allowing the browser to decide what to do but the FileSystemFileHandle does not seem to expose the absoulte path.
Is there any way to open the downloaded file with the default application? If not, what other possibilities are there to make the mentioned use case as simple as possible?

Thanks in advance

EDIT: I found that you can open certain applications using special urls like ms-excel:ofe|u|file://path/to/file.xls . This would be enough for most use cases but for this to work I would need to get the file url from a FileSystemFileHandle .

For security reasons, there is no way for a Web app to open local apps. In the future, though, once file change events are implemented, you can await changes to the file, and then re-open it. This should solve your use case.

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