Skip to content

export Class

File ​

implements ​

Omit<FilePacket, "token" | "rest">

If there is no token set, it will get Token from your environment variables EnvironmentVariables .

Constructor ​

new File( packet )
ts
new File( packet )
ParameterTypeDescription
packetFilePacketThe packet metadata of the file.
new File( file_id )
ts
new File( file_id )
ParameterTypeDescription
file_idstringThe id of the file.
new File( path, options )
ts
new File( path, options )
ParameterTypeDescription
pathstringThe absolute path to the file to attach.
options?FormData.AppendOptionsAdditional append options for uploading file, can be empty.

Properties ​

get form : [string, ReadStream, string | AppendOptions] ​

get id : string ​

get partial : boolean ​

file_id? : string ​

file_path? : string ​

file_size? : number ​

file_unique_id? : string ​

options? : FormData.AppendOptions ​

path? : string ​

rest? : Rest ​

token? : string ​

Methods ​

asyncdownload( path ) ​

ParameterTypeDescription
path?stringThe absolute path to a file where you want to write the data.

Downloads the file, must have a token.

Returns: Promise<boolean | internal.Stream>

asyncfetch( ) ​

Fetches the file, ensure that you have set the token or otherwise it will return the same instance.

Returns: Promise<File>

parse( ) ​

Returns the id of the file or the attach of the attached file.

Returns: string

setToken( token ) ​

ParameterTypeDescription
tokenstringThe token to set, this is exclusive to this class.

Sets the token for fetching and downloading.

Returns: File

A modern, powerful library for building your Telegram bots, with seamless support for both JavaScript and Typescript.