This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.
The FileSystemFileEntry
interface of the File System API represents a file in a file system. It offers properties describing the file's attributes, as well as the file()
method, which creates a File
object that can be used to read the file.
Properties
Inherits the properties of its parent interface, FileSystemEntry
, but has no properties unique to this interface.
Methods
Obsolete methods
createWriter()
'- Creates a new
FileWriter
object which allows writing to the file represented by the file system entry.
Basic concepts
To write content to file, create a FileWriter
object by calling createWriter()
. To read a file, obtain a File
object representing its contents by calling file()
.
Example
The following code creates an empty file called "log.txt"
(if it doesn't exist) and fills it with the text "Meow". Inside the success callback, event handlers are set up to handle the error
error
and writeend
events. The text data is written to the file by creating a blob, appending text to it, and passing the blob to FileWriter.write()
.
function onInitFs(fs) {
fs.root.getFile('log.txt', {create: true}, function(fileEntry) {
// Create a FileWriter object for our FileSystemFileEntry (log.txt).
fileEntry.createWriter(function(fileWriter) {
fileWriter.onwriteend = function(e) {
console.log('Write completed.');
};
fileWriter.onerror = function(e) {
console.log('Write failed: ' + e.toString());
};
// Create a new Blob and write it to log.txt.
var bb = new BlobBuilder();
bb.append('Meow');
fileWriter.write(bb.getBlob('text/plain'));
}, errorHandler);
}, errorHandler);
}
window.requestFileSystem(window.TEMPORARY, 1024*1024, onInitFs, errorHandler);
Specifications
Specification | Status | Comment |
---|---|---|
File and Directory Entries APIThe definition of 'FileSystemFileEntry' in that specification. | Draft | Draft of proposed API |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
FileSystemFileEntry
|
Chrome Full support 8 Full support 8 Alternate Name' Uses the non-standard name: |
Edge Full support 79 Full support 79 Prefixed' Implemented with the vendor prefix: webkit |
Firefox
Full support 50 |
IE
No support No |
Opera
No support No |
Safari
Full support 11.1 |
WebView Android Full support ≤37 Full support ≤37 Alternate Name' Uses the non-standard name: |
Chrome Android Full support 18 Full support 18 Alternate Name' Uses the non-standard name: |
Firefox Android
Full support 50 |
Opera Android
No support No |
Safari iOS
Full support 11.3 |
Samsung Internet Android Full support 1.0 Full support 1.0 Alternate Name' Uses the non-standard name: |
Chrome
Full support 8 |
Edge
Full support 79 |
Firefox No support 50 — 52 No support 50 — 52 Notes' While the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android No support 50 — 52 No support 50 — 52 Notes' While the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 1.0 | |
file
|
Chrome
Full support 8 |
Edge
Full support 79 |
Firefox
Full support 50 |
IE
No support No |
Opera
No support No |
Safari
Full support 11.1 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 50 |
Opera Android
No support No |
Safari iOS
Full support 11.3 |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
- No support
- No support
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- See implementation notes.'
- See implementation notes.
- Uses a non-standard name.'
- Uses a non-standard name.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
FileSystemFileEntry by Mozilla Contributors is licensed under CC-BY-SA 2.5.