This commit is contained in:
Théo LAGACHE
2026-01-07 15:00:11 +01:00
parent da3d4350cc
commit 585ee041ec
38 changed files with 128 additions and 216 deletions
-1
View File
@@ -8,7 +8,6 @@ export async function generateEdgeKey(serverUrl: string, agentId: string): Promi
agentId,
publicKey
};
console.log(edgeKeyData);
const edgeKeyJson = JSON.stringify(edgeKeyData);
const edgeKeyBuffer = Buffer.from(edgeKeyJson, 'utf-8');
return edgeKeyBuffer.toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
+1 -7
View File
@@ -171,22 +171,18 @@ export async function createPresignedUrlToUpload({
return await s3Client.presignedPutObject(bucketName, fileName, expiry);
}
// Function to create a bucket and make it public
export async function createPublicBucket({bucketName}: { bucketName: string }) {
const s3Client = await getS3Client();
try {
// Check if the bucket already exists
const exists = await s3Client.bucketExists(bucketName);
if (!exists) {
// Create the bucket
await s3Client.makeBucket(bucketName); // Change region if needed
await s3Client.makeBucket(bucketName);
console.log(`Bucket ${bucketName} created successfully.`);
} else {
console.log(`Bucket ${bucketName} already exists.`);
}
// Define a bucket policy for public access
const policy = {
Version: "2012-10-17",
Statement: [
@@ -199,7 +195,6 @@ export async function createPublicBucket({bucketName}: { bucketName: string }) {
],
};
// Set the policy to the bucket
await s3Client.setBucketPolicy(bucketName, JSON.stringify(policy));
console.log(`Bucket ${bucketName} is now public.`);
} catch (error) {
@@ -242,7 +237,6 @@ export async function createPresignedUrlToDownload({
bucketName,
fileName,
errorMessage: err?.message,
// stack: err?.stack,
});
throw {error: err.message ?? "Unknown error"};
}