Interface FileWriter

This interface expands on the FileSaver interface to allow for multiple write actions, rather than just saving a single Blob.

Hierarchy

Index

Properties

Methods

Properties

public DONE: number

The entire Blob has been written to the file, an error occurred during the write, or the write was aborted using abort(). The FileSaver is no longer writing the blob.

readonly

public INIT: number

The blob is being written.

readonly

public WRITING: number

The object has been constructed, but there is no pending write.

readonly

public error: DOMError

The last error that occurred on the FileSaver.

readonly

public length: number

The length of the file. If the user does not have read access to the file, this must be the highest byte offset at which the user has written.

public onabort: Function

Handler for abort events.

public onerror: Function

Handler for error events.

public onprogress: Function

Handler for progress events.

public onwrite: Function

Handler for write events.

public onwriteend: Function

Handler for writeend events.

public onwritestart: Function

Handler for writestart events

public position: number

The byte offset at which the next write to the file will occur. This must be no greater than length. A newly-created FileWriter must have position set to 0.

public readyState: number

The FileSaver object can be in one of 3 states. The readyState attribute, on getting, must return the current state, which must be one of the following values:

  • INIT
  • WRITING
  • DONE
    • readonly

Methods

public abort()

When the abort method is called, user agents must run the steps below:

  1. If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything else.
  2. Set readyState to DONE.
  3. If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those tasks.
  4. Terminate the write algorithm being processed.
  5. Set the error attribute to a DOMError object of type "AbortError".
  6. Fire a progress event called abort
  7. Fire a progress event called writeend
  8. Terminate this algorithm.

public addEventListener(type: string, listener: EventListener, useCapture?: boolean)

Parameters

  • type: string
  • listener: EventListener
  • useCapture?: boolean optional

public dispatchEvent(evt: Event): boolean

Parameters

  • evt: Event

Returns

boolean

public removeEventListener(type: string, listener: EventListener, useCapture?: boolean)

Parameters

  • type: string
  • listener: EventListener
  • useCapture?: boolean optional

public seek(offset: number)

Seek sets the file position at which the next write will occur.

Parameters

  • offset: number

    If nonnegative, an absolute byte offset into the file. If negative, an offset back from the end of the file.

public truncate(size: number)

Changes the length of the file to that specified. If shortening the file, data beyond the new length must be discarded. If extending the file, the existing data must be zero-padded up to the new length.

Parameters

  • size: number

    The size to which the length of the file is to be adjusted, measured in bytes.

public write(data: Blob)

Write the supplied data to the file at position.

Parameters

  • data: Blob

    The blob to write.