fix upload file

This commit is contained in:
2026-02-07 15:37:54 +03:30
parent 56e5ac5ec3
commit 9ab0078b43
+5 -1
View File
@@ -37,13 +37,17 @@ export class S3Service {
*/ */
async uploadFile(buffer: Buffer, key: string, contentType: string, metadata?: Record<string, string>): Promise<S3UploadResult> { async uploadFile(buffer: Buffer, key: string, contentType: string, metadata?: Record<string, string>): Promise<S3UploadResult> {
try { try {
const encodedMetadata = metadata ? Object.fromEntries(
Object.entries(metadata).map(([key, value]) => [key, encodeURIComponent(value)])
) : undefined;
const command = new PutObjectCommand({ const command = new PutObjectCommand({
Bucket: this.bucketName, Bucket: this.bucketName,
Key: key, Key: key,
Body: buffer, Body: buffer,
ACL: "public-read", ACL: "public-read",
ContentType: contentType, ContentType: contentType,
Metadata: metadata, Metadata: encodedMetadata,
}); });
await this.s3Client.send(command); await this.s3Client.send(command);