GramIO API Reference / @gramio/contexts/dist / FileDownload
Interface: FileDownload
Defined in: contexts/index.d.ts:103
A lazy, Response-like handle for a file download (returned by bot.downloadFile / context.download). It is a PromiseLike<ArrayBuffer> — so awaiting it yields the bytes — plus readers mirroring the web Response.
(Structural mirror of TelegramFileDownload from @gramio/files; declared here so @gramio/contexts stays dependency-free.)
Extends
PromiseLike<ArrayBuffer>
Methods
arrayBuffer()
arrayBuffer():
Promise<ArrayBuffer>
Defined in: contexts/index.d.ts:107
The whole file as an ArrayBuffer.
Returns
Promise<ArrayBuffer>
blob()
blob():
Promise<Blob>
Defined in: contexts/index.d.ts:111
The whole file as a Blob.
Returns
Promise<Blob>
bytes()
bytes():
Promise<Uint8Array<ArrayBufferLike>>
Defined in: contexts/index.d.ts:109
The whole file as a Uint8Array.
Returns
Promise<Uint8Array<ArrayBufferLike>>
info()
info():
Promise<TelegramFile>
Defined in: contexts/index.d.ts:105
getFile metadata — does not read the body.
Returns
Promise<TelegramFile>
json()
json<
T>():Promise<T>
Defined in: contexts/index.d.ts:115
The file parsed as JSON.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Returns
Promise<T>
link()
link():
Promise<string>
Defined in: contexts/index.d.ts:121
A download URL. Contains the bot token by default; token-less only when files.baseURL is set.
Returns
Promise<string>
stream()
stream():
Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
Defined in: contexts/index.d.ts:117
A web ReadableStream of the file.
Returns
Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
text()
text():
Promise<string>
Defined in: contexts/index.d.ts:113
The file decoded as UTF-8 text.
Returns
Promise<string>
then()
then<
TResult1,TResult2>(onfulfilled?,onrejected?):PromiseLike<TResult1|TResult2>
Defined in: typescript/lib/lib.es5.d.ts:1542
Attaches callbacks for the resolution and/or rejection of the Promise.
Type Parameters
| Type Parameter | Default type |
|---|---|
TResult1 | ArrayBuffer |
TResult2 | never |
Parameters
| Parameter | Type | Description |
|---|---|---|
onfulfilled? | (value) => TResult1 | PromiseLike<TResult1> | The callback to execute when the Promise is resolved. |
onrejected? | (reason) => TResult2 | PromiseLike<TResult2> | The callback to execute when the Promise is rejected. |
Returns
PromiseLike<TResult1 | TResult2>
A Promise for the completion of which ever callback is executed.
Inherited from
PromiseLike.then
toFile()
toFile(
path):Promise<string>
Defined in: contexts/index.d.ts:119
Save the file to path and return it.
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<string>