How to send an image hosted on Amazon S3 through the Facebook Messenger Send API?
Asked Answered
G

1

7

The messenger Send API gives me back the response (#546) The type of file you're trying to attach isn't allowed. Please try again with a different format. error code: 546, error_subcode: 154502

However, if I host the same exact image on Google Cloud instead of Amazon S3, then the image sends fine.

My link to the AWS image: https://s3.amazonaws.com/paloma-staging-public/files/conversation-step-56-80925.gif

My link to the google cloud image: https://storage.googleapis.com/callparty/thumbsup.gif

are there any special reasons that a link to an image stored on S3 would not work as an image attachment, but a link to an image stored on google cloud would work?

Gagliano answered 25/9, 2017 at 18:8 Comment(1)
When I click the AWS link my browser downloads the image. When I click the Google link it opens in the browser. So there must be some differenceMetritis
G
5

The answer was that for the AWS link the ContentType of the file was not set.

While uploading to S3 I had to manually set the ContentType of the file appropriately ("image/gif", "image/png" etc.) and for the google cloud storage this must have been automatically set.

This is why the S3 link causes an auto-download, and the google cloud link displays the image in the browser.

Gagliano answered 25/9, 2017 at 18:37 Comment(1)
there must be also another reason why Facebook Messenger won't serve the images. I have the ContentType set on S3 but still Facebook Messenger (on mobile) won't serve the images in structured messages. However, on the desktop browser version it works fine.Futhark

© 2022 - 2024 — McMap. All rights reserved.