Serverless function UI (#6388)
https://www.figma.com/design/xt8O9mFeLl46C5InWwoMrN/Twenty?node-id=36235-120877 Did not do the file manager part. A Function is defined using one unique file at the moment Feature protected by featureFlag `IS_FUNCTION_SETTINGS_ENABLED` ## Demo https://github.com/user-attachments/assets/0acb8291-47b4-4521-a6fa-a88b9198609b
This commit is contained in:
@ -2,8 +2,11 @@ import { Readable } from 'stream';
|
||||
|
||||
import {
|
||||
CreateBucketCommandInput,
|
||||
DeleteObjectCommand,
|
||||
DeleteObjectsCommand,
|
||||
GetObjectCommand,
|
||||
HeadBucketCommandInput,
|
||||
ListObjectsV2Command,
|
||||
NotFound,
|
||||
PutObjectCommand,
|
||||
S3,
|
||||
@ -53,6 +56,57 @@ export class S3Driver implements StorageDriver {
|
||||
await this.s3Client.send(command);
|
||||
}
|
||||
|
||||
private async emptyS3Directory(folderPath) {
|
||||
const listParams = {
|
||||
Bucket: this.bucketName,
|
||||
Prefix: folderPath,
|
||||
};
|
||||
|
||||
const listObjectsCommand = new ListObjectsV2Command(listParams);
|
||||
const listedObjects = await this.s3Client.send(listObjectsCommand);
|
||||
|
||||
if (listedObjects.Contents?.length === 0) return;
|
||||
|
||||
const deleteParams = {
|
||||
Bucket: this.bucketName,
|
||||
Delete: {
|
||||
Objects: listedObjects.Contents?.map(({ Key }) => {
|
||||
return { Key };
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
const deleteObjectCommand = new DeleteObjectsCommand(deleteParams);
|
||||
|
||||
await this.s3Client.send(deleteObjectCommand);
|
||||
|
||||
if (listedObjects.IsTruncated) {
|
||||
await this.emptyS3Directory(folderPath);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(params: {
|
||||
folderPath: string;
|
||||
filename?: string;
|
||||
}): Promise<void> {
|
||||
if (params.filename) {
|
||||
const deleteCommand = new DeleteObjectCommand({
|
||||
Key: `${params.folderPath}/${params.filename}`,
|
||||
Bucket: this.bucketName,
|
||||
});
|
||||
|
||||
await this.s3Client.send(deleteCommand);
|
||||
} else {
|
||||
await this.emptyS3Directory(params.folderPath);
|
||||
const deleteEmptyFolderCommand = new DeleteObjectCommand({
|
||||
Key: `${params.folderPath}`,
|
||||
Bucket: this.bucketName,
|
||||
});
|
||||
|
||||
await this.s3Client.send(deleteEmptyFolderCommand);
|
||||
}
|
||||
}
|
||||
|
||||
async read(params: {
|
||||
folderPath: string;
|
||||
filename: string;
|
||||
|
||||
Reference in New Issue
Block a user