Module: system/storage-streams

Methods

(static) createFileReadStream(hash, encodingopt) → {SimpleReadStream}

Parameters:
Name Type Attributes Description
hash SHA256Hash

Hash (and filename) of a ONE object, CLOB or BLOB

encoding 'base64' | 'utf8' <optional>

Use 'utf8' for streams of UTF-8 text files if you want them streamed as UTF-8 (otherwise they are just treated as binary streams). Everything else is treated as "binary" and can be streamed as pure binary stream (ArrayBuffer, leave this parameter undefined), or as base64 encoded binary stream (the React Native platform does not support getting binary data across the native-to-Javascript bridge and requires all binary data to be base64 encoded).

For BLOBSs:

  • undefined: binary stream (ArrayBuffer) (not available on React Native)
  • 'base64': base64 encoded binary stream

For ONE objects and CLOBs:

  • 'utf8': UTF-8 string stream of UTF-8 contents

The stream starts automatically as soon as the data event handler function has been added. You can get the positive or negative (error) result from the stream promise at any later time.

Source:
Throws:
  • Throws a synchronous Error if no filename is given

    Type: Error

  • Rejects with an Error whose name property is set to FileNotFoundError if the file cannot be found

    Type: Error

Returns:

Returns a system-dependent readable stream.

Type: SimpleReadStream

(static) createFileWriteStream(encodingopt, filenameopt, typeopt) → {SimpleWriteStream}

Parameters:
Name Type Attributes Default Description
encoding 'base64' | 'utf8' <optional>

'utf8' for text file streams or 'base64' for base64 encoded string streams, undefined for binary streams

filename string <optional>
type StorageDirTypes <optional>
'objects'

Have a look at the description of the SimpleWriteStream object returned by the method.

Source:
Returns:

Returns a simple platform-independent writable stream.

Type: SimpleWriteStream