Skip to content

Commit

Permalink
update: image extension and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinceBaghel258025 committed Nov 16, 2023
1 parent 4798b7b commit 8a4dfe9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/apiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,19 @@ export async function putS3Object(inputParams: {
s3: S3Client;
Body: Buffer;
chatId: string;
chatTitle: string;
}) {
try {
const data = await inputParams.s3.send(
new PutObjectCommand({
Bucket: env.BUCKET_NAME,
Body: inputParams.Body,
Key: `cardimages/${inputParams.chatId}`,
Key: `cardimages/${inputParams.chatId}.png`,
Metadata: {
"Content-Type": "image/png",
"chat-id": inputParams.chatId,
"chat-title": inputParams.chatTitle,
},
}),
);
console.log(
Expand Down Expand Up @@ -193,8 +199,9 @@ export const generateChatImage = async (
s3: s3,
Body: buffer,
chatId,
chatTitle,
});
const image_s3_url = `${env.IMAGE_PREFIX_URL}cardimages/${chatId}`;
const image_s3_url = `${env.IMAGE_PREFIX_URL}cardimages/${chatId}.png`;
console.log("generated image s3 url", image_s3_url);
return image_s3_url;
}
Expand Down

0 comments on commit 8a4dfe9

Please sign in to comment.