FreeRTOS: HTTPS Client
HTTPS Client v1.0.0 library
Return to main page ↑
Upload Demo Usage Instructions
  1. 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
  2. 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
  3. 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:

    https://my-bucket.s3-<region>.amazonaws.com/object-key.txt?AWSAccessKeyId=AAAAAAAAAAAAAAAAAAAA&Expires=1560555644&Signature=SomeHash12345UrlABcdEFgfIjK%3D

    Example:

    https://my-bucket.s3-us-west-2.amazonaws.com/object-key.txt?AWSAccessKeyId=AAAAAAAAAAAAAAAAAAAA&Expires=1560555644&Signature=SomeHash12345UrlABcdEFgfIjK%3D

    Please see https://aws.amazon.com/premiumsupport/knowledge-center/s3-http-307-response/ for more information.

  4. 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.
  5. Enable the Synchronous upload demo by defining CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED in aws_demo_config.h:
    /* To run a particular demo you need to define one of these.
    * Only one demo can be configured at a time
    *
    * CONFIG_MQTT_DEMO_ENABLED
    * CONFIG_SHADOW_DEMO_ENABLED
    * CONFIG_GREENGRASS_DISCOVERY_DEMO_ENABLED
    * CONFIG_TCP_ECHO_CLIENT_DEMO_ENABLED
    * CONFIG_DEFENDER_DEMO_ENABLED
    * CONFIG_POSIX_DEMO_ENABLED
    * CONFIG_OTA_UPDATE_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED
    *
    * These defines are used in iot_demo_runner.h for demo selection */
    #define CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED
  6. 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://sarem-public.s3.amazonaws.com/helloworld5.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&X-Amz-Credential=AKIAIYLZ53PYH6JY77YQ%2F201908313 971 [iot_thread] [INFO ][DEMO][970] File was successfully uploaded.
    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.
  7. Enable the Asynchronous upload demo by defining either CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED in aws_demo_config.h:
    /* To run a particular demo you need to define one of these.
    * Only one demo can be configured at a time
    *
    * CONFIG_MQTT_DEMO_ENABLED
    * CONFIG_SHADOW_DEMO_ENABLED
    * CONFIG_GREENGRASS_DISCOVERY_DEMO_ENABLED
    * CONFIG_TCP_ECHO_CLIENT_DEMO_ENABLED
    * CONFIG_DEFENDER_DEMO_ENABLED
    * CONFIG_POSIX_DEMO_ENABLED
    * CONFIG_OTA_UPDATE_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED
    *
    * These defines are used in iot_demo_runner.h for demo selection */
    #define CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED
  8. 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://sarem-public.s3.amazonaws.com/helloworld5.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&X-Amz-Credential=AKIAIYLZ53PYH6JY77YQ%2F20190813 900 [iot_thread] [INFO ][DEMO][900] Now checking sarem-public.s3.amazonaws.com for the file uploaded...
    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.