HTTP Get file on amazon "S3"
Posted: Wed Oct 26, 2022 3:47 pm
Hello,
I'm using ESP32-C3 with ESP-AT firmware (v2.4...)
Another part has created account on Amazon. Then, We generate some device with certificate.
I convert these certificate (ca, cert and key) with the provided python script AtPKI.py.
Then I flash these files to the ESP32Flash on partition mqtt_ca, mqtt_key and mqtt_cert with the command AT+SYSFLASH.
Then I'm able to connect to the amazon server on MQTT with commands:
- AT+CIPSNTPCFG (set time)
- AT+MQTTUSERCFG
- AT + MQTTCONN..
After that I can publish message and subscribe to a topic.
This work properly (Tested with the MQTT client test on Amazon web interface)
Now I want be able to get a file.
To do that, I upload my file on "amazon S3" module.
This module allow me to upload a file and generate an url (for some couple of hour).
The generated URL is like this:
https://<mysite>-sandbox-ota.s3.eu-west-1.amazonaws.com/<myrep>/<myfile>.xxx?response-content-disposition=inline&X-Amz-Security-Token=IQoJb3JpZ2luX2V[....]Amz-Date=20221026T151421Z&X-Amz-SignedHeaders=host&X-Amz-Expires=43200&X-Amz-Credential=ASIAWXYV5C2B6FEAXLEB%2F2022[....]
If I copy/paste this URL into my web browser, the file is downloaded. Then the link is good.
Now I want download this file with the ESP32.
Like the URL is > 256 Byte, I write the follwoing command:
- AT+HTTPURLCFG=1668
- >
- <myURL>
- AT+HTTPURLCFG? -> return my URL.
Follwing is my terminal view with different try:
17:42:13.407 [TX] - AT+HTTPGETSIZE=""
17:42:13.422 [RX] - AT+HTTPGETSIZE=""
17:42:13.998 [RX] -
ERROR
17:45:13.470 [RX] - AT+HTTPGETSIZE="https://<mysite>-ota.s3.eu-west-1.amazonaws.com/<myrep>/<myfile>.xxx"
17:45:14.046 [RX] - +HTTPGETSIZE:0
OK
17:42:40.587 [TX] - AT+HTTPCLIENT=2,0,"","https://<mysite>-sandbox-ota.s3.eu-west-1.amazonaws.com","/<myrep>",2
17:42:40.600 [RX] - AT+HTTPCLIENT=2,0,"","https://<mysite>-sandbox-ota.s3.eu-west-1.amazonaws.com","/<myrep>",2
17:42:41.228 [RX] - ERR CODE:0x010a7190
ERROR
17:43:24.569 [TX] - AT+HTTPCLIENT=2,0,"",,,2
17:43:24.585 [RX] - AT+HTTPCLIENT=2,0,"",,,2
17:43:25.128 [RX] - ERR CODE:0x010a7000
ERROR
Now if I create a local HTTP server on my computer, and just use AT+HTTPURLCFG=xx then My local url.
Then I get the size and then the file with following commands:
AT+HTTPCLIENT=2,0,"",,,2
AT+HTTPGETSIZE=""
All work properly.
In other word, I get error only with amazon file..
I think there are certificate problem?? But the url contains the key...
Where is my mistake?
Are they exemple to get HTTP file on amazon s3 server?
Regards
I'm using ESP32-C3 with ESP-AT firmware (v2.4...)
Another part has created account on Amazon. Then, We generate some device with certificate.
I convert these certificate (ca, cert and key) with the provided python script AtPKI.py.
Then I flash these files to the ESP32Flash on partition mqtt_ca, mqtt_key and mqtt_cert with the command AT+SYSFLASH.
Then I'm able to connect to the amazon server on MQTT with commands:
- AT+CIPSNTPCFG (set time)
- AT+MQTTUSERCFG
- AT + MQTTCONN..
After that I can publish message and subscribe to a topic.
This work properly (Tested with the MQTT client test on Amazon web interface)
Now I want be able to get a file.
To do that, I upload my file on "amazon S3" module.
This module allow me to upload a file and generate an url (for some couple of hour).
The generated URL is like this:
https://<mysite>-sandbox-ota.s3.eu-west-1.amazonaws.com/<myrep>/<myfile>.xxx?response-content-disposition=inline&X-Amz-Security-Token=IQoJb3JpZ2luX2V[....]Amz-Date=20221026T151421Z&X-Amz-SignedHeaders=host&X-Amz-Expires=43200&X-Amz-Credential=ASIAWXYV5C2B6FEAXLEB%2F2022[....]
If I copy/paste this URL into my web browser, the file is downloaded. Then the link is good.
Now I want download this file with the ESP32.
Like the URL is > 256 Byte, I write the follwoing command:
- AT+HTTPURLCFG=1668
- >
- <myURL>
- AT+HTTPURLCFG? -> return my URL.
Follwing is my terminal view with different try:
17:42:13.407 [TX] - AT+HTTPGETSIZE=""
17:42:13.422 [RX] - AT+HTTPGETSIZE=""
17:42:13.998 [RX] -
ERROR
17:45:13.470 [RX] - AT+HTTPGETSIZE="https://<mysite>-ota.s3.eu-west-1.amazonaws.com/<myrep>/<myfile>.xxx"
17:45:14.046 [RX] - +HTTPGETSIZE:0
OK
17:42:40.587 [TX] - AT+HTTPCLIENT=2,0,"","https://<mysite>-sandbox-ota.s3.eu-west-1.amazonaws.com","/<myrep>",2
17:42:40.600 [RX] - AT+HTTPCLIENT=2,0,"","https://<mysite>-sandbox-ota.s3.eu-west-1.amazonaws.com","/<myrep>",2
17:42:41.228 [RX] - ERR CODE:0x010a7190
ERROR
17:43:24.569 [TX] - AT+HTTPCLIENT=2,0,"",,,2
17:43:24.585 [RX] - AT+HTTPCLIENT=2,0,"",,,2
17:43:25.128 [RX] - ERR CODE:0x010a7000
ERROR
Now if I create a local HTTP server on my computer, and just use AT+HTTPURLCFG=xx then My local url.
Then I get the size and then the file with following commands:
AT+HTTPCLIENT=2,0,"",,,2
AT+HTTPGETSIZE=""
All work properly.
In other word, I get error only with amazon file..
I think there are certificate problem?? But the url contains the key...
Where is my mistake?
Are they exemple to get HTTP file on amazon s3 server?
Regards