-
Ensure that you have permissions in your AWS account to access S3.
For information on AWS S3 please see: https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html
-
Install and configured the AWS CLI.
For AWS CLI installation information please see: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
For AWS CLI configuration information please see: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
-
Run demos/https/presigned_url_gen.py with your s3 bucket-name and s3 object key object-key.
python presigned_url_gen.py --bucket my-bucket --key object-key
Please see demos/https/README.md for information on the required Python version and Python package dependencies.
Example output:
#define IOT_DEMO_HTTPS_PRESIGNED_GET_URL https://aws-s3-endpoint/object-key.txt?AWSAccessKeyId=AAAAAAAAAAAAAAAAAAAA&Expires=1560555644&Signature=SomeHash12345UrlABcdEFgfIjK%3D
#define IOT_DEMO_HTTPS_PRESIGNED_PUT_URL https://aws-s3-endpoint/object-key.txt?AWSAccessKeyId=ABABABABABABABABABAB&Expires=1560555644&Signature=SomeHash12345UrlLMnmOPqrStUvW
Paste this output to iot_config.h.
Note:
If your bucket is less than 24 hours old, then you will need to append the region the bucket was created in to the pre-signed URL:
Example:
Please see https://aws.amazon.com/premiumsupport/knowledge-center/s3-http-307-response/ for more information.
-
Paste your RSA-2048 or ECC-P256 keys into aws_clientcredential_keys.h. This is needed to for the TLS handshake with the AWS S3 HTTP Server.
-
Enable the Synchronous upload demo by defining CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED in aws_demo_config.h:
#define CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED
-
See Building the demo applications for instructions on building the demo.
A successful output looks like this: 10 621 [iot_thread] [INFO ][INIT][621] SDK successfully initialized.
11 621 [iot_thread] [INFO ][DEMO][621] Successfully initialized the demo. Network type for the demo: 4
12 621 [iot_thread] [INFO ][DEMO][621] HTTPS Client Synchronous S3 upload demo using pre-signed URL: https:
14 971 [iot_thread] [INFO ][DEMO][971] Now checking sarem-public.s3.amazonaws.com for the file uploaded...
15 1010 [iot_thread] [INFO ][DEMO][1010] Verified file size on S3 is 12. File size specified to upload is 12.
16 1070 [iot_thread] [INFO ][DEMO][1070] Demo completed successfully.
17 1073 [iot_thread] [INFO ][INIT][1073] SDK cleanup done.
-
Enable the Asynchronous upload demo by defining either CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED in aws_demo_config.h:
#define CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED
-
See Building the demo applications for instructions on building the demo.
A successful output looks like this:
10 610 [iot_thread] [INFO ][INIT][610] SDK successfully initialized.
11 610 [iot_thread] [INFO ][DEMO][610] Successfully initialized the demo. Network type for the demo: 4
12 610 [iot_thread] [INFO ][DEMO][610] HTTPS Client Asynchronous S3 upload demo using pre-signed URL: https:
14 940 [iot_thread] [INFO ][DEMO][940] Verified file size on S3 is 12. File size specified to upload is 12.
15 1000 [iot_thread] [INFO ][DEMO][1000] Demo completed successfully.
16 1002 [iot_thread] [INFO ][INIT][1002] SDK cleanup done.
Notes:
Please note that the buffer for printing may be smaller than 512 characters and the printed received response body may be truncated.