import { AirplaneFileObject } from "./file_object"; /** * AirplaneFile is a helper for reading and writing files. It can be used to fetch the contents * of a file parameter and can be passed as a file parameter when executing a task. * * The AirplaneFile API mirrors [the Blob API](https://developer.mozilla.org/en-US/docs/Web/API/Blob). Unlike * Blob, AirplaneFile lazily loads the contents of the file. This allows AirplaneFile to be used as a reference * to a file without having to download its contents (e.g. passing a parameter from one task to another). * @example * function(params) { * const file = new AirplaneFile(params.my_file); * const contents = await file.text() * console.log(`got: ${contents}`) * } */ export declare class AirplaneFile { #private; /** * The `__airplaneType` field identifies objects as a specific type of Airplane object. Airplane files are * identified by the type, "upload". */ readonly __airplaneType = "upload"; /** * A unique identifier of this file assigned by Airplane once uploaded. * * This will be an empty string if the file has not yet been uploaded. */ id: string; /** * A URL that identifies where this file is hosted. * * When received as a task or prompt parameter value, this URL will be short-lived signed URL that can be fetched * with an HTTP GET request. The easiest way to fetch the contents are by calling one of the content-fetching * methods on this class, such as `.text()`. * * This will be an empty string if the file has not yet been uploaded. */ url: string; /** * The name of this file. */ name: string; /** * The size, in bytes, of this file. * * This will be zero if the file has not been downloaded yet. In that case, call `.download()`. */ size: number; /** * The MIME type of the file. * * This will be an empty string if the file has not been downloaded yet. In that case, call `.download()`. * @see https://developer.mozilla.org/en-US/docs/Web/API/Blob/type */ type: string; /** * Initialize an AirplaneFile from an object. */ constructor(obj: AirplaneFileObject); /** * Initialize an AirplaneFile from a Blob. * @param source * @param metadata */ constructor(source: Blob, metadata?: { id?: string; url?: string; name?: string; }); toJSON(): AirplaneFileObject; /** * @returns a Promise that resolves with a string containing the contents of the AirplaneFile, interpreted as UTF-8. * @see https://developer.mozilla.org/en-US/docs/Web/API/Blob/text */ text(): Promise; /** * Similar to `text()`, except that it deserializes the contents as JSON. Throws an error if the contents are not valid JSON. * @returns a Promise that resolves with a JSON object representing the contents of the AirplaneFile, interpreted as UTF-8 and unmarshalled as JSON. */ json(): Promise; /** * @returns a Promise that resolves with the contents of the AirplaneFile as binary data contained in an ArrayBuffer. * @see https://developer.mozilla.org/en-US/docs/Web/API/Blob/arrayBuffer */ arrayBuffer(): Promise; /** * Downloads the contents of this file, if not already downloaded. * * AirplaneFiles are lazily-initialized so the file's contents are only downloaded upon request. This * method can be called to ensure that the file's contents have been downloaded which ensures that * values such as `type` or `size` will have been set. */ download(): Promise; } export declare const upload: (payload: Blob | string, fileName?: string) => Promise;