Class: HttpFileStream

HttpFileStream(file, mode)

An advanced file stream implementation for remote HTTP files. This class can be used for random file access of remote files.

Constructor

new HttpFileStream(file, mode)

Construct a file stream from an HttpFile. This will create a wrapper stream that will route read() and write() to the FileChannel
Parameters:
Name Type Description
file IFile The HttpFile that will be used to get the read/write stream
mode string The mode "r" for read "rw" for write
Source:

Classes

HttpFileStream

Methods

(async) canRead() → {Promise.<boolean>}

True if stream can read from file.
Source:
Returns:
True if it can read.
Type
Promise.<boolean>

(async) canSeek() → {Promise.<boolean>}

True if stream can seek.
Source:
Returns:
True if it can seek
Type
Promise.<boolean>

(async) canWrite() → {Promise.<boolean>}

True if stream can write to file.
Source:
Returns:
True if it can write
Type
Promise.<boolean>

(async) close()

Close this stream and associated resources.
Source:
Throws:
IOException Thrown if there is an IO error.

flush()

Flush the buffers to the associated file.
Source:

(async) getLength() → {Promise.<number>}

Get the length of the stream. This is the same as the backed file.
Source:
Returns:
The length
Type
Promise.<number>

(async) getPosition() → {Promise.<number>}

Get the current position of the stream.
Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
The position
Type
Promise.<number>

(async) read(buffer, offset, count) → {Promise.<number>}

Read data from the file stream into the buffer provided.
Parameters:
Name Type Description
buffer Uint8Array The buffer to write the data.
offset number The offset of the buffer to start writing the data.
count number The maximum number of bytes to read from.
Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
The number of bytes read
Type
Promise.<number>

(async) reset()

Reset the stream.
Source:

(async) seek(offset, origin) → {Promise.<number>}

Seek to the offset provided.
Parameters:
Name Type Description
offset number The position to seek to.
origin SeekOrigin The type of origin SeekOrigin
Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
The new position after seeking.
Type
Promise.<number>

(async) setLength(value)

Set the length of the stream. This is applicable for write streams only.
Parameters:
Name Type Description
value number The new length.
Source:
Throws:
IOException Thrown if there is an IO error.

(async) setPosition(value)

Set the current position of the stream.
Parameters:
Name Type Description
value number The new position.
Source:
Throws:
IOException Thrown if there is an IO error.

(async) write(buffer, offset, count)

Write the data from the buffer provided into the stream.
Parameters:
Name Type Description
buffer Uint8Array The buffer to read the data from.
offset number The offset of the buffer to start reading the data.
count number The maximum number of bytes to read from the buffer.
Source:
Throws:
IOException Thrown if there is an IO error.