Downloading chunk to SD Card
Posted: Fri Feb 01, 2019 4:17 am
Hi Everyone,
I am currently working with the esp_http_client_example program and am having a little bit of trouble accessing chunk data once it has been downloaded.
It seems a little difficult but from the looks of it, I have to pull it from the struct? (which isn't publicly exposed?) Just wanted to check I'm not missing something completely.
I have placed the function down below for reference. Please note the SD write function just writes a char array to the SD card.
Any help is much appreciated!
Tom
I am currently working with the esp_http_client_example program and am having a little bit of trouble accessing chunk data once it has been downloaded.
It seems a little difficult but from the looks of it, I have to pull it from the struct? (which isn't publicly exposed?) Just wanted to check I'm not missing something completely.
I have placed the function down below for reference. Please note the SD write function just writes a char array to the SD card.
Any help is much appreciated!
Tom
Code: Select all
static void http_download_chunk()
{
esp_http_client_config_t config = {
.url = "REDACTED URL",
.event_handler = _http_event_handler,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
ESP_LOGI(TAG, "HTTP chunk encoding Status = %d, content_length = %d", esp_http_client_get_status_code(client), esp_http_client_get_content_length(client));
} else {
ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));
}
//ESP_LOGI(TAG, "%d", client->response->data_process);
SD_write_flash_images(BIN_ID, client->response->buffer->output_ptr, (uint32_t)client->response->buffer->raw_len);
ESP_LOGI(TAG, "Image Written to SD Card %i", client->response->buffer->raw_len);
esp_http_client_cleanup(client);
}