fix upload file
This commit is contained in:
@@ -37,13 +37,17 @@ export class S3Service {
|
||||
*/
|
||||
async uploadFile(buffer: Buffer, key: string, contentType: string, metadata?: Record<string, string>): Promise<S3UploadResult> {
|
||||
try {
|
||||
const encodedMetadata = metadata ? Object.fromEntries(
|
||||
Object.entries(metadata).map(([key, value]) => [key, encodeURIComponent(value)])
|
||||
) : undefined;
|
||||
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: this.bucketName,
|
||||
Key: key,
|
||||
Body: buffer,
|
||||
ACL: "public-read",
|
||||
ContentType: contentType,
|
||||
Metadata: metadata,
|
||||
Metadata: encodedMetadata,
|
||||
});
|
||||
|
||||
await this.s3Client.send(command);
|
||||
|
||||
Reference in New Issue
Block a user