Skip to main content

Class: Collection

Defined in: bee-js/src/modules/collection.ts:21

Collection (multi-file) operations backed by the /bzz endpoint.

Accessed as bee.collection.

Constructors​

Constructor​

new Collection(context): Collection

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

Parameters​

context​

BeeContext

Returns​

Collection

Methods​

hashDirectory()​

hashDirectory(dir): Promise<Reference>

Defined in: bee-js/src/modules/collection.ts:169

Hashes a directory locally and returns the root hash (Swarm reference).

The actual Swarm reference may be different as there is no canonical hashing of directories.

Parameters​

dir​

string

Returns​

Promise<Reference>


stream()​

stream(postageBatchId, files, onUploadProgress?, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/modules/collection.ts:112

Uploads a collection of files by streaming them to the Bee node, which supports arbitrary sizes, but may be slower due to uploading chunks one by one.

Only intended for the browser environment.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

files​

File[] | FileList

onUploadProgress?​

(progress) => void

options?​

UploadOptions

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<UploadResult>


streamFromDirectory()​

streamFromDirectory(postageBatchId, dir, onUploadProgress?, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/modules/collection.ts:143

Uploads a directory by streaming its contents directly to the Bee node, which supports arbitrary directory sizes, but may be slower due to uploading chunks one by one.

Only intended for the Node.js environment.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

dir​

string

onUploadProgress?​

(progress) => void

options?​

CollectionUploadOptions

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<UploadResult>


upload()​

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

Defined in: bee-js/src/modules/collection.ts:32

Uploads a collection that you assemble yourself.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

collection​

Collection

options?​

CollectionUploadOptions

Collection and request options

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<UploadResult>


uploadFromDirectory()​

uploadFromDirectory(postageBatchId, dir, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/modules/collection.ts:83

Uploads a collection of files from a directory on the filesystem.

Available only in Node.js as it uses the fs module.

Parameters​

postageBatchId​

Postage BatchId to be used to upload the data with

string | Uint8Array<ArrayBufferLike> | BatchId

dir​

string

the path of the files to be uploaded

options?​

CollectionUploadOptions

Additional options like tag, encryption, pinning and request options

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<UploadResult>


uploadFromFileList()​

uploadFromFileList(postageBatchId, fileList, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/modules/collection.ts:56

Uploads a collection of files using the browser FileList API.

Parameters​

postageBatchId​

Postage BatchId to be used to upload the data with

string | Uint8Array<ArrayBufferLike> | BatchId

fileList​

list of files to be uploaded

File[] | FileList

options?​

CollectionUploadOptions

Additional options like tag, encryption, pinning and request options

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<UploadResult>

💬 Get Help