Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 659
maxfowler Avatar asked Sep 25 '17 18:09

maxfowler


People also ask

How do I upload images to Amazon S3?

To upload folders and files to an S3 bucketSign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to upload your folders or files to. Choose Upload.

What is S3 API?

The S3 API is an application programming interface that provides the capability to store, retrieve, list and delete objects (or binary files) in S3. When first released in 2006, the S3 API supported REST, SOAP and BitTorrent protocols as well as development through an SDK for common programming languages such as Java .

Is S3 used for media hosting?

As you could see Amazon S3 offers a great solution for hosting your media content while decreasing the load of your primary web server. There are some obvious advantages including pay as you go model and unlimited scalability.


1 Answers

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.

like image 172
maxfowler Avatar answered Oct 07 '22 23:10

maxfowler