[HN Gopher] New Patterns for Apps
___________________________________________________________________
New Patterns for Apps
Author : tomayac
Score : 37 points
Date : 2022-10-10 18:44 UTC (4 hours ago)
(HTM) web link (web.dev)
(TXT) w3m dump (web.dev)
| skybrian wrote:
| Under "how to save a file" [1] it tries to use
| window.showSaveFilePicker (which has poor browser support) and
| falls back on creating an invisible link and clicking on it.
|
| It seems a bit much, versus just having a download link, possibly
| styling it as a button. What do you get for that?
|
| [1] https://web.dev/patterns/files/
| easrng wrote:
| They're assuming you generated the file in the browser and you
| don't have a link from a server.
| skybrian wrote:
| It's possible to create a temporary URL (with data from an
| ArrayBuffer) entirely client side:
|
| URL.createObjectURL(new Blob(...));
|
| It creates a blob: URL that you can use as a link.
| tomayac wrote:
| The advantage of using the `showSaveFilePicker()` method is
| that you can get a `FileSystemFileHandle`, with which you can
| then implement a true "edit, save, edit, save,..." flow; always
| saving over the current file, instead of downloading copies on
| each "save".
| modeless wrote:
| In the future you may even be able to save the handle and
| retain permission to the file or directory between page
| reloads or even browser restart. I've been experimenting with
| this in Chrome. There's a preliminary implementation behind a
| flag (--enable-
| features=kFileSystemAccessPersistentPermissions).
|
| The preliminary implementation is still buggy, but it's an
| extremely useful feature. You could use it to e.g. make a web
| version of VSCode that only ever has to request permission to
| your workspace directory once, and can then edit any file in
| it without constant permission requests, just like the
| Electron version of VSCode. (The persistent file access
| permission is displayed in the address bar and can be revoked
| at any time).
___________________________________________________________________
(page generated 2022-10-10 23:00 UTC)