Class: File
Defined in: bee-js/src/modules/file.ts:16
Single-file operations backed by the /bzz endpoint.
Accessed as bee.file.
Constructors
Constructor
new File(
context):File
Defined in: bee-js/src/modules/file.ts:17
Parameters
context
BeeContext
Returns
File
Methods
download()
download(
resource,path,options?,requestOptions?):Promise<FileData<Bytes>>
Defined in: bee-js/src/modules/file.ts:74
Downloads a single file.
Parameters
resource
Swarm reference, Swarm CID, or ENS domain.
string | Uint8Array<ArrayBufferLike> | Reference
path
string = ''
If reference points to manifest, then this parameter defines path to the file
options?
Options that affects the request behavior
requestOptions?
Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
Returns
downloadReadable()
downloadReadable(
reference,path,options?,requestOptions?):Promise<FileData<ReadableStream<Uint8Array<ArrayBufferLike>>>>
Defined in: bee-js/src/modules/file.ts:100
Downloads a single file as a readable stream.
Parameters
reference
Bee file reference in hex string (either 64 or 128 chars long), ENS domain or Swarm CID.
string | Uint8Array<ArrayBufferLike> | Reference
path
string = ''
If reference points to manifest / collections, then this parameter defines path to the file
options?
Options that affects the request behavior
requestOptions?
Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
Returns
Promise<FileData<ReadableStream<Uint8Array<ArrayBufferLike>>>>
upload()
upload(
postageBatchId,data,name?,options?,requestOptions?):Promise<UploadResult>
Defined in: bee-js/src/modules/file.ts:30
Uploads a single file to a Bee node.
To download the file, use download.
Parameters
postageBatchId
Postage BatchId to be used to upload the data with
string | Uint8Array<ArrayBufferLike> | BatchId
data
Data or file to be uploaded
string | Uint8Array<ArrayBufferLike> | File | Readable
name?
string
Optional name of the uploaded file
options?
Additional options like tag, encryption, pinning, content-type and request options
requestOptions?
Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
Returns
Promise<UploadResult>