diff --git a/packages/client/src/methods/files/download-iterable.ts b/packages/client/src/methods/files/download-iterable.ts index 3a15bc4c..f1e2e8bb 100644 --- a/packages/client/src/methods/files/download-iterable.ts +++ b/packages/client/src/methods/files/download-iterable.ts @@ -8,6 +8,7 @@ import { FileDownloadParameters, FileLocation, } from '../../types' +import { fileIdToInputFileLocation } from '@mtcute/file-id' /** * Download a file and return it as an iterable, which yields file contents @@ -52,6 +53,9 @@ export async function* downloadAsIterable( if (!fileSize) fileSize = location.fileSize location = location.location as any } + if (typeof location === 'string') { + location = fileIdToInputFileLocation(location) + } // we will receive a FileMigrateError in case this is invalid if (!dcId) dcId = this._primaryDc.id diff --git a/packages/client/src/types/files/utils.ts b/packages/client/src/types/files/utils.ts index dd4bca38..7574b62a 100644 --- a/packages/client/src/types/files/utils.ts +++ b/packages/client/src/types/files/utils.ts @@ -49,9 +49,10 @@ export type InputFileLike = export interface FileDownloadParameters { /** - * File location which should be downloaded + * File location which should be downloaded. + * You can also provide TDLib and Bot API compatible File ID */ - location: tl.TypeInputFileLocation | FileLocation + location: tl.TypeInputFileLocation | FileLocation | string /** * Total file size, if known.