• Upload a file to Telegram servers, without actually sending a message anywhere. Useful when an InputFile is required.

    This method is quite low-level, and you should use other methods like sendMedia that handle this under the hood.

    Parameters

    • client: ITelegramClient
    • params: {
          estimatedSize?: number;
          file: UploadFileLike;
          fileMime?: string;
          fileName?: string;
          fileSize?: number;
          partSize?: number;
          progressCallback?: ((uploaded: number, total: number) => void);
          requestsPerConnection?: number;
          requireExtension?: boolean;
          requireFileSize?: boolean;
      }

      Upload parameters

      • OptionalestimatedSize?: number

        If the file size is unknown, you can provide an estimate, which will be used to determine appropriate part size.

      • file: UploadFileLike

        Upload file source.

      • OptionalfileMime?: string

        File MIME type. By default is automatically inferred from magic number If MIME can't be inferred, it defaults to application/octet-stream

      • OptionalfileName?: string

        File name for the uploaded file. Is usually inferred from path, but should be provided for files sent as Buffer or stream.

        When file name can't be inferred, it falls back to "unnamed"

      • OptionalfileSize?: number

        Total file size. Automatically inferred for Buffer, File and local files.

      • OptionalpartSize?: number

        Upload part size (in KB).

        By default, automatically selected by file size. Must not be bigger than 512 and must not be a fraction.

      • OptionalprogressCallback?: ((uploaded: number, total: number) => void)

        Function that will be called after some part has been uploaded.

          • (uploaded, total): void
          • Parameters

            • uploaded: number

              Number of bytes already uploaded

            • total: number

              Total file size, if known

            Returns void

      • OptionalrequestsPerConnection?: number

        Number of parts to be sent in parallel per connection.

      • OptionalrequireExtension?: boolean

        When using inputMediaUploadedPhoto (e.g. when sending an uploaded photo) require the file extension to be known beforehand.

        This will make the library try to guess the file extension from the file mime type, or throw an error if it cannot be guessed.

      • OptionalrequireFileSize?: boolean

        When using inputMediaUploadedPhoto (e.g. when sending an uploaded photo) require the file size to be known beforehand.

        In case this is set to true, a stream is passed as file and the file size is unknown, the stream will be buffered in memory and the file size will be inferred from the buffer.

    Returns Promise<UploadedFile>