2025-06-11 20:07:12 +02:00
|
|
|
import { DeleteObjectCommand } from '@aws-sdk/client-s3';
|
2025-02-20 08:55:25 +01:00
|
|
|
|
2025-06-11 00:14:17 +02:00
|
|
|
import { FileAttributes } from '@colanode/core';
|
|
|
|
|
import { s3Client } from '@colanode/server/data/storage';
|
|
|
|
|
import { config } from '@colanode/server/lib/config';
|
2025-02-12 21:45:02 +01:00
|
|
|
|
|
|
|
|
export const buildFilePath = (
|
|
|
|
|
workspaceId: string,
|
|
|
|
|
fileId: string,
|
|
|
|
|
fileAttributes: FileAttributes
|
|
|
|
|
) => {
|
|
|
|
|
return `files/${workspaceId}/${fileId}_${fileAttributes.version}${fileAttributes.extension}`;
|
|
|
|
|
};
|
2025-02-20 08:55:25 +01:00
|
|
|
|
|
|
|
|
export const deleteFile = async (path: string) => {
|
|
|
|
|
const command = new DeleteObjectCommand({
|
2025-06-11 20:07:12 +02:00
|
|
|
Bucket: config.storage.bucket,
|
2025-02-20 08:55:25 +01:00
|
|
|
Key: path,
|
|
|
|
|
});
|
|
|
|
|
|
2025-06-11 00:14:17 +02:00
|
|
|
await s3Client.send(command);
|
2025-02-20 08:55:25 +01:00
|
|
|
};
|