UNPKG

@composio/core

Version:

![Composio Banner](https://github.com/user-attachments/assets/9ba0e9c1-85a4-4b51-ae60-f9fe7992e819)

51 lines (49 loc) 1.48 kB
import "../chunk-CWQeghP5.mjs"; import "../ComposioError-ChkSdxqU.mjs"; import { t as telemetry } from "../Telemetry-CjVa99gU.mjs"; import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-BOZnseMe.mjs"; //#region src/models/Files.node.ts var Files = class { constructor(client) { this.client = client; telemetry.instrument(this, "Files"); } /** * Upload a file and return the file data. * * @param params - The upload parameters. * @param {File | string} params.file - The path to the file to upload, a URL of the file, or a File object. * @param {string} params.toolSlug - The slug of the tool that is uploading the file. * @param {string} params.toolkitSlug - The slug of the toolkit that is uploading the file. * @returns {Promise<FileUploadData>} The uploaded file data. * * @example * * const fileData = await composio.files.upload({ * file: 'path/to/file.pdf', * toolSlug: 'google_drive_upload', * toolkitSlug: 'google_drive' * }); * */ async upload({ file, toolSlug, toolkitSlug }) { return await getFileDataAfterUploadingToS3(file, { toolSlug, toolkitSlug, client: this.client }); } /** * Download a file from S3 and return the file data. * @param s3key - The S3 key of the file to download. * @returns The file data. */ async download({ toolSlug, s3Url, mimeType }) { return await downloadFileFromS3({ toolSlug, s3Url, mimeType }); } }; //#endregion export { Files };