DRAFT
This page is not complete.
The Device Storage API is an API to manipulate the file system in a web app.
API
Entry point
var deviceStorage = navigator.getDeviceStorage(directory)
The directory is a string refering to the type of storage. It can be any string and denotes a repository. Some directories are defined by the system, like 'videos' or 'pictures'. TODO find the full list of system directories
DeviceStorage instances
- deviceStorage.type
-
May be
"external","shared", or"default".
- deviceStorage.add(blob)
-
Adds a file (which content is the
blobargument) to the storage. The operation is asynchronous so it returns a DOMRequest which contains the file name (automatically generated).
- deviceStorage.addNamed(blob, name)
-
Same as
.addbut the file name is provided as argument. If the name already exists, the DOMRequest fails.
- deviceStorage.get(name)
-
Returns a DOMRequest for a file with the given
name. If successful, the DOMRequest result will be a (non-editable) File object.
- deviceStorage.getEditable(name)
-
Same as
.get, but the success value will be a FileHandle object
- deviceStorage.delete(name)
- Returns a DOMRequest for the success or failure of the file deletion
- deviceStorage.enumerate([directory])
-
Returns a DeviceStorageCursor that enumerates Files in the storage or the
directory(string) passed as argument
- deviceStorage.enumerateEditable([directory])
-
Same as
.enumerate, but enumerates FileHandles
Description
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | ? | ? | Not supported | Not supported | Not supported |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | ? | ? | Not supported | Not supported | Not supported |
Mozilla Developer Network