Uploading media files to send with WhatsApp
When you send or receive a media file, it has to be stored in an Amazon S3 bucket. The Amazon S3 bucket must be in the same AWS account and AWS Region as your WhatsApp Business Account (WABA). These directions show how to create an Amazon S3 bucket, upload a file, and build the URL to the file. For more information on Amazon S3 commands, see Use high-level (s3) commands with the AWS CLI. For more information on configuring the AWS CLI, see Configure the AWS CLI in the AWS Command Line Interface User Guide, and Creating a bucket, and Uploading objects in the Amazon S3 User Guide.
You can also create a presigned URL to the media file. With a presigned URL, you can grant time-limited access to objects and upload them without requiring another party to have AWS security credentials or permissions.
To create an Amazon S3 bucket, use the create-bucket
aws s3api create-bucket --region '
us-east-1
' --bucketBucketName
In the preceding command:
-
Replace
us-east-1
with the AWS Region that your WABA is in. Replace
BucketName
with the name of the new bucket.
To copy a file to the Amazon S3 bucket, use the cp AWS CLI command. At the command line, enter the following command:
aws s3 cp
SourceFilePathAndName
s3://BucketName
/FileName
In the preceding command:
Replace
SourceFilePathAndName
with the file path and name of the file to copy.Replace
BucketName
with the name of the bucket.Replace
FileName
with the name to use for the file.
The url to use when sending is:
s3://
BucketName
/FileName
To create a presigned URL, replace the user input
placeholders
with your own information.
aws s3 presign s3://
amzn-s3-demo-bucket1
/mydoc.txt
--expires-in604800
--regionaf-south-1
--endpoint-urlhttps://s3.af-south-1.amazonaws.com
The returned URL will be:
https://amzn-s3-demo-bucket1.s3.af-south-1.amazonaws.com/mydoc.txt?{Headers}