FileSystemWritableFileStream: seek() method

Baseline 2025
Newly available

Since September 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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

Note: This feature is available in Web Workers.

The seek() method of the FileSystemWritableFileStream interface updates the current file cursor offset to the position (in bytes) specified when calling the method.

Syntax

js
seek(position)

Parameters

position

A number specifying the byte position from the beginning of the file.

Return value

A Promise that returns undefined.

Exceptions

NotAllowedError DOMException

Thrown if PermissionStatus.state is not granted.

TypeError

Thrown if position is not a number or not defined.

Examples

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

Next, we write to the stream:

  1. A text string is written to the stream.
  2. The seek() method is used to put the cursor at the start of the stream.
  3. A second text string is written to the start of the stream, overwriting the first write.

The stream is then closed.

js
async function saveFile() {
  try {
    // 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("My first file content");
    await writableStream.seek(0);
    await writableStream.write("My second file content");

    // close the file and write the contents to disk.
    await writableStream.close();
  } catch (err) {
    console.error(err.name, err.message);
  }
}

If you run the above function and then open the resulting file created on disk, you should see the text "My second file content".

Specifications

Specification
File System
# api-filesystemwritablefilestream-seek

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
seek
Chrome – Full support
Chrome 86 (Release date: 2020-10-20)
footnote Full support
Edge – Full support
Edge 86 (Release date: 2020-10-09)
footnote Full support
Firefox – Full support
Firefox 111 (Release date: 2023-03-14)
footnote Full support
Opera – Full support
Opera 72 (Release date: 2020-10-21)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 111 (Release date: 2023-03-14)
footnote Full support
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also