/** * File Upload Support for Telegram Bot API * * Handles multipart/form-data file uploads for local files. * Supports detection of local file paths and creation of form-data requests. */ /** * Parameters that can contain file uploads, mapped by API method */ export declare const FILE_UPLOAD_PARAMS: Record; /** * Methods that support file uploads */ export declare const FILE_UPLOAD_METHODS: Set; /** * Check if a value represents a local file path * * Detection rules: * - Starts with "/" and file exists -> local file * - Starts with "file://" -> local file (strip prefix) * - Is alphanumeric with underscores/hyphens -> file_id (pass as-is) * - Starts with http:// or https:// -> URL (pass as-is) */ export declare function isLocalFilePath(value: unknown): boolean; /** * Extract the actual file path from a value */ export declare function extractFilePath(value: string): string; /** * Check if a value is a file_id (Telegram's internal file identifier) * File IDs are base64-like strings with alphanumerics, underscores, and hyphens */ export declare function isFileId(value: unknown): boolean; /** * Check if a value is an HTTP/HTTPS URL */ export declare function isHttpUrl(value: unknown): boolean; /** * Determine the type of file reference */ export type FileReferenceType = "local_file" | "file_id" | "url" | "unknown"; export declare function getFileReferenceType(value: unknown): FileReferenceType; export interface FileInfo { path: string; name: string; size: number; mimeType: string; } /** * Get file information for a local file */ export declare function getFileInfo(filePath: string): FileInfo; /** * File entry for multipart form-data */ interface FormDataFile { paramName: string; filePath: string; fileName: string; mimeType: string; } /** * Result of checking params for file uploads */ export interface FileUploadCheck { hasFiles: boolean; files: FormDataFile[]; cleanParams: Record; } /** * Check if parameters contain any local file uploads * Returns information about files found and cleaned params */ export declare function checkForFileUploads(method: string, params: Record): FileUploadCheck; /** * Result of creating multipart form-data */ export interface MultipartFormData { body: Buffer; contentType: string; boundary: string; } /** * Create a multipart/form-data request body * * @param params - The cleaned parameters (with attach:// references for files) * @param files - Array of file information * @returns The form-data body buffer and content-type header */ export declare function createMultipartFormData(params: Record, files: FormDataFile[]): MultipartFormData; /** * Validate that all referenced files exist * * @param files - Array of file information * @throws Error if any file doesn't exist */ export declare function validateFiles(files: FormDataFile[]): void; export {}; //# sourceMappingURL=index.d.ts.map