feat: implement media backup (ZIP) and migration tools

This commit is contained in:
Erik
2026-03-07 18:29:01 -03:00
parent 0c40dbadfc
commit c3d0676c4f
5 changed files with 407 additions and 92 deletions

View File

@@ -1,4 +1,4 @@
import { S3Client, HeadBucketCommand, CreateBucketCommand, PutBucketPolicyCommand, PutObjectCommand, DeleteObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
import { S3Client, HeadBucketCommand, CreateBucketCommand, PutBucketPolicyCommand, PutObjectCommand, DeleteObjectCommand, GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';
const endpointHost = process.env.MINIO_ENDPOINT || 'localhost';
const port = Number.parseInt(process.env.MINIO_PORT || '9000', 10);
@@ -10,7 +10,7 @@ console.log(`[MinIO] Configurando cliente: ${endpointHost}:${port} (SSL: ${useSS
export const bucketName = process.env.MINIO_BUCKET_NAME || 'occto-images';
const s3Client = new S3Client({
export const s3Client = new S3Client({
region: 'us-east-1',
endpoint: endpointUrl,
forcePathStyle: true,
@@ -84,6 +84,11 @@ export const minioClient = {
async removeObject(bucket: string, key: string) {
await s3Client.send(new DeleteObjectCommand({ Bucket: bucket, Key: key }));
},
async listObjects(bucket: string) {
const command = new ListObjectsV2Command({ Bucket: bucket });
return s3Client.send(command);
},
};
// Garante que o bucket exista antes de qualquer upload