Skip to content

Latest commit

 

History

History
102 lines (64 loc) · 2.94 KB

storage.md

File metadata and controls

102 lines (64 loc) · 2.94 KB

Storage

import { ... } from 'react-firehooks/storage';

useBlob

Returns the data of a Google Cloud Storage object as a Blob

This hook is not available in Node.

const [data, loading, error] = useBlob(storageReference);

Params:

  • reference: Reference to a Google Cloud Storage object
  • maxDownloadSizeBytes: If set, the maximum allowed size in bytes to retrieve.

Returns:

  • value: Object data as a Blob; undefined if data of the object is currently being downloaded, or an error occurred
  • loading: true while downloading the data of the object; false if the data was downloaded successfully or an error occurred
  • error: undefined if no error occurred

useBytes

Returns the data of a Google Cloud Storage object

const [data, loading, error] = useBytes(storageReference);

Params:

  • reference: Reference to a Google Cloud Storage object
  • maxDownloadSizeBytes: If set, the maximum allowed size in bytes to retrieve.

Returns:

  • value: Object data; undefined if data of the object is currently being downloaded, or an error occurred
  • loading: true while downloading the data of the object; false if the data was downloaded successfully or an error occurred
  • error: undefined if no error occurred

useDownloadURL

Returns the download URL of a Google Cloud Storage object

const [url, loading, error] = useDownloadURL(storageReference);

Params:

  • reference: Reference to a Google Cloud Storage object

Returns:

  • value: Download URL; undefined if download URL is currently being fetched, or an error occurred
  • loading: true while fetching the download URL; false if the download URL was fetched successfully or an error occurred
  • error: undefined if no error occurred

useMetadata

Returns the metadata of a Google Cloud Storage object

const [metadata, loading, error] = useMetadata(storageReference);

Params:

  • reference: Reference to a Google Cloud Storage object

Returns:

  • value: Metadata; undefined if metadata is currently being fetched, or an error occurred
  • loading: true while fetching the metadata; false if the metadata was fetched successfully or an error occurred
  • error: undefined if no error occurred

useStream

Returns the data of a Google Cloud Storage object as a stream

This hook is only available in Node.

const [data, loading, error] = useStream(storageReference);

Params:

  • reference: Reference to a Google Cloud Storage object
  • maxDownloadSizeBytes: If set, the maximum allowed size in bytes to retrieve.

Returns:

  • value: Object data as a stream; undefined if data of the object is currently being downloaded, or an error occurred
  • loading: true while downloading the data of the object; false if the data was downloaded successfully or an error occurred
  • error: undefined if no error occurred