import { APIResource } from "../core/resource.js"; import { APIPromise } from "../core/api-promise.js"; import { CursorURLPage, PagePromise } from "../core/pagination.js"; import { type Uploadable } from "../core/uploads.js"; import { RequestOptions } from "../internal/request-options.js"; export declare class Files extends APIResource { /** * Create a file by uploading its content and optional metadata. * * Example cURL request: * * ```console * curl -X POST https://api.replicate.com/v1/files \ * -H "Authorization: Token $REPLICATE_API_TOKEN" \ * -H 'Content-Type: multipart/form-data' \ * -F 'content=@/path/to/archive.zip;type=application/zip;filename=example.zip' \ * -F 'metadata={"customer_reference_id": 123};type=application/json' * ``` * * The request must include: * * - `content`: The file content (required) * - `type`: The content / MIME type for the file (defaults to * `application/octet-stream`) * - `filename`: The filename (required, ≤ 255 bytes, valid UTF-8) * - `metadata`: User-provided metadata associated with the file (defaults to `{}`, * must be valid JSON) */ create(body: FileCreateParams, options?: RequestOptions): APIPromise; /** * Get a paginated list of all files created by the user or organization associated * with the provided API token. * * Example cURL request: * * ```console * curl -s \ * -H "Authorization: Token $REPLICATE_API_TOKEN" \ * https://api.replicate.com/v1/files * ``` * * The response will be a paginated JSON array of file objects, sorted with the * most recent file first. */ list(options?: RequestOptions): PagePromise; /** * Delete a file. Once a file has been deleted, subsequent requests to the file * resource return 404 Not found. * * Example cURL request: * * ```console * curl -X DELETE \ * -H "Authorization: Token $REPLICATE_API_TOKEN" \ * https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o * ``` */ delete(params: FileDeleteParams, options?: RequestOptions): APIPromise; /** * Download a file by providing the file owner, access expiry, and a valid * signature. * * Example cURL request: * * ```console * curl -X GET "https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o/download?expiry=1708515345&owner=mattt&signature=zuoghqlrcnw8YHywkpaXQlHsVhWen%2FDZ4aal76dLiOo%3D" * ``` */ download(params: FileDownloadParams, options?: RequestOptions): APIPromise; /** * Get the details of a file. * * Example cURL request: * * ```console * curl -s \ * -H "Authorization: Token $REPLICATE_API_TOKEN" \ * https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o * ``` */ get(params: FileGetParams, options?: RequestOptions): APIPromise; } export type FileListResponsesCursorURLPage = CursorURLPage; /** * A file resource */ export interface FileCreateResponse { /** * A unique, randomly-generated identifier for the file resource */ id: string; /** * A dictionary of checksums for the file keyed by the algorithm name */ checksums: FileCreateResponse.Checksums; /** * The content / MIME type of the file */ content_type: string; /** * When the file was created */ created_at: string; /** * When the file expires */ expires_at: string; /** * Metadata provided by user when the file was created */ metadata: unknown; /** * The length of the file in bytes */ size: number; /** * A dictionary of URLs associated with the file resource */ urls: FileCreateResponse.URLs; } export declare namespace FileCreateResponse { /** * A dictionary of checksums for the file keyed by the algorithm name */ interface Checksums { /** * SHA256 checksum of the file */ sha256?: string; } /** * A dictionary of URLs associated with the file resource */ interface URLs { /** * A URL to the file resource */ get?: string; } } /** * A file resource */ export interface FileListResponse { /** * A unique, randomly-generated identifier for the file resource */ id: string; /** * A dictionary of checksums for the file keyed by the algorithm name */ checksums: FileListResponse.Checksums; /** * The content / MIME type of the file */ content_type: string; /** * When the file was created */ created_at: string; /** * When the file expires */ expires_at: string; /** * Metadata provided by user when the file was created */ metadata: unknown; /** * The length of the file in bytes */ size: number; /** * A dictionary of URLs associated with the file resource */ urls: FileListResponse.URLs; } export declare namespace FileListResponse { /** * A dictionary of checksums for the file keyed by the algorithm name */ interface Checksums { /** * SHA256 checksum of the file */ sha256?: string; } /** * A dictionary of URLs associated with the file resource */ interface URLs { /** * A URL to the file resource */ get?: string; } } /** * A file resource */ export interface FileGetResponse { /** * A unique, randomly-generated identifier for the file resource */ id: string; /** * A dictionary of checksums for the file keyed by the algorithm name */ checksums: FileGetResponse.Checksums; /** * The content / MIME type of the file */ content_type: string; /** * When the file was created */ created_at: string; /** * When the file expires */ expires_at: string; /** * Metadata provided by user when the file was created */ metadata: unknown; /** * The length of the file in bytes */ size: number; /** * A dictionary of URLs associated with the file resource */ urls: FileGetResponse.URLs; } export declare namespace FileGetResponse { /** * A dictionary of checksums for the file keyed by the algorithm name */ interface Checksums { /** * SHA256 checksum of the file */ sha256?: string; } /** * A dictionary of URLs associated with the file resource */ interface URLs { /** * A URL to the file resource */ get?: string; } } export interface FileCreateParams { /** * The file content */ content: Uploadable; /** * The filename */ filename?: string; /** * User-provided metadata associated with the file */ metadata?: unknown; /** * The content / MIME type for the file */ type?: string; } export interface FileDeleteParams { /** * The ID of the file to delete */ file_id: string; } export interface FileDownloadParams { /** * Path param: The ID of the file to download */ file_id: string; /** * Query param: A Unix timestamp with expiration date of this download URL */ expiry: number; /** * Query param: The username of the user or organization that uploaded the file */ owner: string; /** * Query param: A base64-encoded HMAC-SHA256 checksum of the string '{owner} {id} * {expiry}' generated with the Files API signing secret */ signature: string; } export interface FileGetParams { /** * The ID of the file to get */ file_id: string; } export declare namespace Files { export { type FileCreateResponse as FileCreateResponse, type FileListResponse as FileListResponse, type FileGetResponse as FileGetResponse, type FileListResponsesCursorURLPage as FileListResponsesCursorURLPage, type FileCreateParams as FileCreateParams, type FileDeleteParams as FileDeleteParams, type FileDownloadParams as FileDownloadParams, type FileGetParams as FileGetParams, }; } //# sourceMappingURL=files.d.ts.map