/Web APIs


Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The FileSystemWritableFileStream interface of the File System Access API is a WritableStream object with additional convenience methods, which operates on a single file on disk. The interface is accessed through the FileSystemFileHandle.createWritable() method.

WritableStream FileSystemWritableFileStream

Instance properties

Inherits properties from its parent, WritableStream.

Instance methods

Inherits methods from its parent, WritableStream.


Writes content into the file the method is called on, at the current file cursor offset.


Updates the current file cursor offset to the position (in bytes) specified.


Resizes the file associated with the stream to be the specified size in bytes.


This asynchronous function opens the 'Save File' picker, which returns a FileSystemFileHandle once a file is selected. From which a writable stream is then created using the FileSystemFileHandle.createWritable() method.

A user defined Blob is then written to the stream which is subsequently closed.

async function saveFile() {
  // create a new handle
  const newHandle = await window.showSaveFilePicker();

  // create a FileSystemWritableFileStream to write to
  const writableStream = await newHandle.createWritable();

  // write our file
  await writableStream.write(imgBlob);

  // close the file and write the contents to disk.
  await writableStream.close();

The following show different examples of options that can be passed into the write() method.

// just pass in the data (no options)

// writes the data to the stream from the determined position
writableStream.write({ type: "write", position, data });

// updates the current file cursor offset to the position specified
writableStream.write({ type: "seek", position });

// resizes the file to be size bytes long
writableStream.write({ type: "truncate", size });


Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
FileSystemWritableFileStream 86 86 111 No 72 No No No 111 No No No
seek 86 86 111 No 72 No No No 111 No No No
truncate 86 86 111 No 72 No No No 111 No No No
write 86 86 111 No 72 No No No 111 No No No

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.