My goal is to send an image from s3 via whatsapp. If i get the pre-signed url from the aws console, i can send the image as expected, i receive 200 and its shows up on the chat. But when i get the url from aws-sdk on a lambda function, i recceive 200 but the image does not appear in the chat. Both urls i can acess in any browser normally. Im testing the chat message sending in postman.
My code on lambda: import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'; import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
const s3Client = new S3Client({ region: 'MY_REGION' });
export const handler = async (event) => { let params = { Bucket: 'BUCKET_NAME', Key: 'OBJECT_KEY', Expires: 3600 }; try { const command = new GetObjectCommand(params); const presignedUrl = await getSignedUrl(s3Client, command, { expiresIn: params.Expires }); return presignedUrl; } catch (error) { return error; }
};
I checked policy and roles, do i need to check something else? How can i get from the sdk the same kind of presinged url as the console, so i can send in the cloud api?