So i am using a lambda function to do this, but for some reason the image doesnt show, how can i display my images from s3? here is an example link: https://beconnectedtest-apex-home-kdanibeconnectedbucket11-7dpaorylr8fc.s3.eu-central-1.amazonaws.com/U065SLKNC2Y/1701873226742
And here is my function:
// Upload the post to the daily private channel.
const file = `https://${bucketName}.s3.eu-central-1.amazonaws.com/${metaData.userid}/${metaData.timestamp}`
console.log(`File path: ${file}`)
await app.client.chat.postMessage({
channel: dailyChannel.channels.find(
(channel: any) => channel.name === dailyChannelName
).id,
attachments: [
{
fallback: 'Uploaded a new picture',
title: 'from BeConnected',
text: `<@${metaData.userid}> Uploaded a new picture + https://${bucketName}.s3.eu-central-1.amazonaws.com/${metaData.userid}/${metaData.timestamp}`,
image_url: `https://${bucketName}.s3.eu-central-1.amazonaws.com/${metaData.userid}/${metaData.timestamp}`,
},
],
})
} }
I expected the image to show in the messages, just like if i send an image from my pc directly.
//EDIT Here is where and how I upload the image to s3, maybe that's where the problem i really have no idea. I only started using slack and aws about a few weeks
// Upload the image to S3
const response = await fetch(uploadUrl, {
method: 'PUT',
body: mergedImage,
headers: {
'Content-Type': 'image/png', // Specify the correct header for content type
},
})
Okay the issue was that i uploaded the image as base64 text because I used canvas.toDataUrl instead of canvas.toBlob, I changed it and finally it works fine!