Skip to content

GramIO API Reference / @gramio/files/dist

@gramio/files/dist

Classes

ClassDescription
MediaInputClass-helper with static methods that represents the content of a media message to be sent.
MediaUploadClass-helper with static methods for file uploading.

Variables

MEDIA_METHODS

const MEDIA_METHODS: MethodsWithMediaUpload

Defined in: files/index.d.ts:41

A set of methods with the function of checking whether a File has been passed in the parameters

Codegenerated

Functions

convertJsonToFormData()

convertJsonToFormData<T>(method, params): Promise<FormData>

Defined in: files/index.d.ts:12

Helper to convert JSON to FormData that can accept Telegram Bot API. if File is not top-level property it will be “attach://<file_attach_name>”

Documentation

Type Parameters

Type Parameter
T extends keyof APIMethods

Parameters

ParameterType
methodT
paramsNonNullable<APIMethodParams<T>>

Returns

Promise<FormData>


convertStreamToBuffer()

convertStreamToBuffer(stream): Promise<Buffer<ArrayBufferLike>>

Defined in: files/index.d.ts:21

Helper for convert Readable stream to buffer

Parameters

ParameterType
streamReadable

Returns

Promise<Buffer<ArrayBufferLike>>


extractFilesToFormData()

extractFilesToFormData<T>(method, params): Promise<[FormData, NonNullable<APIMethodParams<T>>]>

Defined in: files/index.d.ts:19

Helper to extract files from params and convert them to FormData. (Similar to convertJsonToFormData) if File is not top-level property it will be “attach://<file_attach_name>”

Documentation

Type Parameters

Type Parameter
T extends keyof APIMethods

Parameters

ParameterType
methodT
paramsNonNullable<APIMethodParams<T>>

Returns

Promise<[FormData, NonNullable<APIMethodParams<T>>]>


isBlob()

isBlob(blob?): boolean

Defined in: files/index.d.ts:35

Guard to check is it Blob or Promise

Parameters

ParameterType
blob?string | object | Blob

Returns

boolean


isMediaUpload()

isMediaUpload<T>(method, params): boolean

Defined in: files/index.d.ts:5

Guard to check is method used for File Uploading

Type Parameters

Type Parameter
T extends keyof APIMethods

Parameters

ParameterType
methodT
paramsNonNullable<APIMethodParams<T>>

Returns

boolean