Skip to main content
Module

x/grammy_files/files.ts>FileX

Handle and download received media files.
Latest
interface FileX
import { type FileX } from "https://deno.land/x/grammy_files@v1.1.0/files.ts";

Methods

getUrl(): string

Computes a URL from the file_path property of this file object. The URL can be used to download the file contents.

If you are using a local Bot API server, then this method will return the file path that identifies the local file on your system.

If the file_path of this file object is undefined, this method will throw an error.

Note that this method is installed by grammY on the File object.

download(path?: string): Promise<string>

This method will download the file from the Telegram servers and store it under the given file path on your system. It returns the absolute path to the created file, so this may be the same value as the argument to the function.

If you omit the path argument to this function, then a temporary file will be created for you. This path will still be returned, hence giving you access to the downloaded file.

If you are using a local Bot API server, then the local file will be copied over to the specified path, or to a new temporary location.

If the file_path of this file object is undefined, this method will throw an error.

Note that this method is installed by grammY on the File object.