You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-35Lines changed: 50 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,32 @@
1
1
# Native File System adapter (ponyfill)
2
2
3
-
> This is an in-browser file system that follows [native-file-system](https://wicg.github.io/native-file-system/) and supports storing and retrieving files from various backends.
3
+
What is this?
4
+
5
+
This is file system that follows [native-file-system](https://wicg.github.io/native-file-system/) specification. Thanks to it we can have a unified way of handling data in all browser and even in NodeJS in a more secure way.
6
+
7
+
At a high level what we're providing is several bits:
8
+
9
+
1. A modernized version of `FileSystemFileHandle` and `FileSystemDirectoryHandle` interfaces.
10
+
2. A modernized version of `FileSystemWritableFileStream` to truncate and write data.
11
+
3. A way to not only use one location to read & write data to and from, but several other sources called adapters
4
12
5
13
### Adapters
6
14
7
-
This polyfill/ponyfill ships with 5 filesystem backends:
15
+
This polyfill/ponyfill ships with a few backends built in:
8
16
9
-
*`native`: Stores files the `Native Sandboxed` file storage
17
+
*`node`: Interact with filesystem using nodes `fs`
18
+
*`native`: Stores files the `Native Sandboxed` file file system storage
10
19
*`Sandbox`: Stores files into the Blinks `Sandboxed FileSystem` API.
11
20
*`IndexedDB`: Stores files into the browser's `IndexedDB` object database.
12
21
*`Memory`: Stores files in-memory. Thus, it is a temporary file store that clears when the user navigates away.
13
22
*`Cache storage`: Stores files in cache storage like a request/response a-like.
14
23
24
+
You can even load in your own underlying adapter and get the same set of API's
25
+
15
26
The api is designed in such a way that it can work with or without the ponyfill if you choose to remove or add this.<br>
16
-
It's not trying to interfear with the changing spec by using other properties that may conflict with the feature changes to the spec. A few none spec options are prefixed with a `_`
27
+
It's not trying to interfere with the changing spec by using other properties that may conflict with the feature changes to the spec.
17
28
18
-
( The current minium supported browser I have choosen to support is the ones that can handle import/export )<br>
29
+
( The current minium supported browser I have chosen to support is the ones that can handle import/export )<br>
@@ -113,7 +133,7 @@ Will get to it at some point in the feature
113
133
114
134
Saving/downloading a file borrowing some of ideas from [StreamSaver.js](https://github.com/jimmywarting/StreamSaver.js).
115
135
The difference is:
116
-
- Using service worker is optional choice with this adapter. 🤷
136
+
- Using service worker is optional choice with this adapter.
117
137
- It dose not rely on some man-in-the-middle or external hosted service worker.
118
138
- If you want to stream large data to the disk directly instead of taking up much RAM you need to set up a service worker yourself.<br>(note that it requires https - but again worker is optional)
119
139
- You don't have to handle web-streams-polyfills it's lazy loaded when needed when you need that writable stream. 😴
Without service worker you are going to write all data to the memory and download it once it closes.
128
148
129
-
Seeking and truncating won't do anything. You should be writing all data in sequental order when using the polyfilled version.
130
-
131
-
-----
132
-
133
-
If you have chosen to `open-directory` when the polyfilled version is in use (`input[webkitdirectory]`)
134
-
than you can't get any write access to it. So unless you are using chanary with experimental flags or enabled the [Origin Trials](https://github.com/GoogleChrome/OriginTrials/blob/gh-pages/developer-guide.md) for beta testing on your origin, then you better use `save-file` instead to be safe. It's also possible to query/request permission.
149
+
Seeking and truncating won't do anything. You should be writing all data in sequential order when using the polyfilled version.
135
150
136
151
### Testing
137
152
138
-
start up a server and open `/examples/test.html` in your browser.
139
-
153
+
-start up a server and open `/examples/test.html` in your browser.
0 commit comments