Skip to main content

Class: Data

Defined in: bee-js/src/modules/data.ts:22

Raw data operations backed by the /bytes endpoint.

Accessed as bee.data.

Constructors

Constructor

new Data(context): Data

Defined in: bee-js/src/modules/data.ts:23

Parameters

context

BeeContext

Returns

Data

Methods

download()

download(resource, options?, requestOptions?): Promise<Bytes>

Defined in: bee-js/src/modules/data.ts:58

Downloads raw data through the GET /bytes/{reference} endpoint.

Parameters

resource

Swarm reference, Swarm CID, or ENS domain.

string | Uint8Array<ArrayBufferLike> | Reference

options?

DownloadOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns

Promise<Bytes>


downloadReadable()

downloadReadable(resource, options?, requestOptions?): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

Defined in: bee-js/src/modules/data.ts:79

Downloads raw data through the GET /bytes/{reference} endpoint as a readable stream.

Only tested in Node.js environment.

Parameters

resource

Swarm reference, Swarm CID, or ENS domain.

string | Uint8Array<ArrayBufferLike> | Reference

options?

DownloadOptions

Options that affects the request behavior.

requestOptions?

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns

Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>


isRetrievable()

isRetrievable(reference, requestOptions?): Promise<boolean>

Defined in: bee-js/src/modules/data.ts:116

Checks if content specified by reference is retrievable from the network.

Parameters

reference

Bee reference to be checked in hex string (either 64 or 128 chars long) or ENS domain.

string | Uint8Array<ArrayBufferLike> | Reference

requestOptions?

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns

Promise<boolean>


probe()

probe(reference, requestOptions?): Promise<ReferenceInformation>

Defined in: bee-js/src/modules/data.ts:101

Fetches content length for a /bytes reference through the HEAD /bytes/{reference} endpoint.

Parameters

reference

string | Uint8Array<ArrayBufferLike> | Reference

requestOptions?

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns

Promise<ReferenceInformation>


upload()

upload(postageBatchId, data, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/modules/data.ts:35

Uploads raw data through the POST /bytes endpoint.

Data uploaded with this method should be retrieved with download.

Parameters

postageBatchId

Usable Postage Batch ID with sufficient capacity to upload the data.

string | Uint8Array<ArrayBufferLike> | BatchId

data

A string (text data) or Uint8Array (raw data) to be uploaded.

string | Uint8Array<ArrayBufferLike> | Blob | Readable

options?

RedundantUploadOptions

Additional options like tag, encryption, pinning, content-type and request options.

requestOptions?

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns

Promise<UploadResult>

💬 Get Help