Download file from presigned url
Posted: Fri Apr 28, 2023 10:04 am
I'm trying to download a text-file from a pre-sigend AWS S3 url using the esp http client but I'm running into some issues. With the code-sample appended at the end of the post, I can download the Google logo (the url used), the sequence of events will be something like:
While, if I used a pre-signed url for a file on S3 I only get:
I verified both links in Python, and this row works fine for both urls:
I'm using ESP-IDF 4.4 and I've set the following in the config:
Anyone who has seen anything similar, has tried downloading from a pre-signed S3 link or has any idea how I can debug this?
BR
Max
Code: Select all
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP_EVENT_ON_HEADER
HTTP_EVENT_ON_HEADER
more HTTP_EVENT_ON_HEADER ...
HTTP_EVENT_ON_DATA
more HTTP_EVENT_ON_DATA ...
HTTP_EVENT_ON_FINISH
HTTP_EVENT_DISCONNECTED
Code: Select all
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_ERROR
HTTP_EVENT_DISCONNECTED
Code: Select all
requests.get(url, verify=False)
I'm using ESP-IDF 4.4 and I've set the following in the config:
- Enable ESP-TLS Serve
- Allow potentially insecure options
- Skip server certificate verification by default
Anyone who has seen anything similar, has tried downloading from a pre-signed S3 link or has any idea how I can debug this?
BR
Max
Code: Select all
esp_err_t _https_event_handle(esp_http_client_event_t *evt) {
switch(evt->event_id) {
case HTTP_EVENT_ERROR:
cout << "HTTP_EVENT_ERROR" << endl;
break;
case HTTP_EVENT_ON_CONNECTED:
cout << "HTTP_EVENT_ON_CONNECTED" << endl;
break;
case HTTP_EVENT_HEADER_SENT:
cout << "HTTP_EVENT_HEADER_SENT" << endl;
break;
case HTTP_EVENT_ON_HEADER:
cout << "HTTP_EVENT_ON_HEADER" << endl;
break;
case HTTP_EVENT_ON_DATA:
cout << "HTTP_EVENT_ON_DATA" << endl;
break;
case HTTP_EVENT_ON_FINISH:
cout << "HTTP_EVENT_ON_FINISH" << endl;
break;
case HTTP_EVENT_DISCONNECTED:
cout << "HTTP_EVENT_DISCONNECTED" << endl;
break;
}
return ESP_OK;
}
void get_data()
{
esp_http_client_config_t config = {
.url = "https://www.google.se/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png",
.cert_pem = NULL,
.method = HTTP_METHOD_GET,
.timeout_ms = 10000,
.event_handler = _https_event_handle,
.transport_type = HTTP_TRANSPORT_OVER_SSL,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);
esp_http_client_cleanup(client);
}