@composio/core
Version:

50 lines (48 loc) • 1.48 kB
JavaScript
require('../buffer-CYf1Z6Sd.cjs');
const require_Telemetry = require('../Telemetry-DErMJqj0.cjs');
const require_fileUtils_node = require('../fileUtils.node-DLp53qm1.cjs');
//#region src/models/Files.node.ts
var Files = class {
constructor(client) {
this.client = client;
require_Telemetry.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 require_fileUtils_node.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 require_fileUtils_node.downloadFileFromS3({
toolSlug,
s3Url,
mimeType
});
}
};
//#endregion
exports.Files = Files;