Prepare for release 0.2.0 (#49)

This commit is contained in:
Hakan Shehu
2025-06-11 20:07:12 +02:00
committed by GitHub
parent 9e6d53d147
commit 29d7fcdb0d
18 changed files with 48 additions and 144 deletions

View File

@@ -1,10 +1,4 @@
import {
PutObjectCommand,
DeleteObjectCommand,
GetObjectCommand,
HeadObjectCommand,
} from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { DeleteObjectCommand } from '@aws-sdk/client-s3';
import { FileAttributes } from '@colanode/core';
import { s3Client } from '@colanode/server/data/storage';
@@ -18,59 +12,9 @@ export const buildFilePath = (
return `files/${workspaceId}/${fileId}_${fileAttributes.version}${fileAttributes.extension}`;
};
export const buildUploadUrl = async (
path: string,
size: number,
mimeType: string
) => {
const command = new PutObjectCommand({
Bucket: config.storage.bucketName,
Key: path,
ContentLength: size,
ContentType: mimeType,
});
const expiresIn = 60 * 60 * 4; // 4 hours
const presignedUrl = await getSignedUrl(s3Client, command, {
expiresIn,
});
return presignedUrl;
};
export const buildDownloadUrl = async (path: string) => {
const command = new GetObjectCommand({
Bucket: config.storage.bucketName,
Key: path,
});
const presignedUrl = await getSignedUrl(s3Client, command, {
expiresIn: 60 * 60 * 4, // 4 hours
});
return presignedUrl;
};
export const fetchFileMetadata = async (path: string) => {
const command = new HeadObjectCommand({
Bucket: config.storage.bucketName,
Key: path,
});
try {
const headObject = await s3Client.send(command);
return {
size: headObject.ContentLength,
mimeType: headObject.ContentType,
};
} catch {
return null;
}
};
export const deleteFile = async (path: string) => {
const command = new DeleteObjectCommand({
Bucket: config.storage.bucketName,
Bucket: config.storage.bucket,
Key: path,
});