diff --git a/callback/web_crawler_callback.c b/callback/web_crawler_callback.c index 918c449..2ee8307 100644 --- a/callback/web_crawler_callback.c +++ b/callback/web_crawler_callback.c @@ -58,17 +58,28 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context) { if (!sent_http_request) { - snprintf( - fhttp.file_path, - sizeof(fhttp.file_path), - STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler/received_data.txt"); - - fhttp.save_received_data = true; + if (app_instance->file_type && app_instance->file_rename) + { + snprintf( + fhttp.file_path, + sizeof(fhttp.file_path), + STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler/%s%s", + app_instance->file_rename, + app_instance->file_type); + } + else + { + snprintf( + fhttp.file_path, + sizeof(fhttp.file_path), + STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler/received_data.txt"); + } if (strstr(app_instance->http_method, "GET") != NULL) { canvas_draw_str(canvas, 0, 10, "Sending GET request..."); + fhttp.save_received_data = true; fhttp.is_bytes_request = false; // Perform GET request and handle the response @@ -85,6 +96,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context) { canvas_draw_str(canvas, 0, 10, "Sending POST request..."); + fhttp.save_received_data = true; fhttp.is_bytes_request = false; // Perform POST request and handle the response @@ -94,6 +106,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context) { canvas_draw_str(canvas, 0, 10, "Sending PUT request..."); + fhttp.save_received_data = true; fhttp.is_bytes_request = false; // Perform PUT request and handle the response @@ -103,6 +116,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context) { canvas_draw_str(canvas, 0, 10, "Sending DELETE request..."); + fhttp.save_received_data = true; fhttp.is_bytes_request = false; // Perform DELETE request and handle the response @@ -113,6 +127,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context) // download file canvas_draw_str(canvas, 0, 10, "Downloading file..."); + fhttp.save_received_data = false; fhttp.is_bytes_request = true; // Perform GET request and handle the response @@ -1046,6 +1061,16 @@ void web_crawler_setting_item_file_read_clicked(void *context, uint32_t index) } UNUSED(index); widget_reset(app->widget_file_read); + + if (app->file_rename && app->file_type) + { + snprintf(fhttp.file_path, sizeof(fhttp.file_path), "%s%s%s", RECEIVED_DATA_PATH, app->file_rename, app->file_type); + } + else + { + snprintf(fhttp.file_path, sizeof(fhttp.file_path), "%s%s%s", RECEIVED_DATA_PATH, "received_data", ".txt"); + } + // load the received data from the saved file FuriString *received_data = flipper_http_load_from_file(fhttp.file_path); if (received_data == NULL) diff --git a/flip_storage/web_crawler_storage.c b/flip_storage/web_crawler_storage.c index c02bbfb..9ae884e 100644 --- a/flip_storage/web_crawler_storage.c +++ b/flip_storage/web_crawler_storage.c @@ -13,7 +13,7 @@ void save_settings( { // Create the directory for saving settings char directory_path[256]; - snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler_app"); + snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler"); // Create the directory Storage *storage = furi_record_open(RECORD_STORAGE); diff --git a/flipper_http/flipper_http.h b/flipper_http/flipper_http.h index 4310256..fb134b2 100644 --- a/flipper_http/flipper_http.h +++ b/flipper_http/flipper_http.h @@ -10,7 +10,7 @@ // STORAGE_EXT_PATH_PREFIX is defined in the Furi SDK as /ext -#define HTTP_TAG "WebCrawler" // change this to your app name +#define HTTP_TAG "Web Crawler" // change this to your app name #define http_tag "web_crawler" // change this to your app id #define UART_CH (FuriHalSerialIdUsart) // UART channel #define TIMEOUT_DURATION_TICKS (5 * 1000) // 5 seconds diff --git a/web_crawler.h b/web_crawler.h index 97ee13d..eb94639 100644 --- a/web_crawler.h +++ b/web_crawler.h @@ -9,7 +9,7 @@ #include "web_crawler_icons.h" #include -#define TAG "WebCrawler" +#define TAG "Web Crawler" extern char *http_method_names[]; // Define the submenu items for our WebCrawler application