file storage web access URL changed from "file" to "storage"

This commit is contained in:
Bogdan Pilyugin 2023-01-22 15:41:38 +02:00
parent 40ebb5d752
commit 0f75145a5f
2 changed files with 7 additions and 7 deletions

View File

@ -103,7 +103,7 @@ static const char* get_path_from_uri(char *dest, const char *base_path,
/* Construct full path (base + path) */ /* Construct full path (base + path) */
strcpy(dest, base_path); strcpy(dest, base_path);
strlcpy(dest + base_pathlen, uri + (sizeof("/files")-1), pathlen + 1 - (sizeof("/files")-1)); strlcpy(dest + base_pathlen, uri + (sizeof("/storage")-1), pathlen + 1 - (sizeof("/storage")-1));
/* Return pointer to path, skipping the base */ /* Return pointer to path, skipping the base */
return dest + base_pathlen; return dest + base_pathlen;
@ -184,7 +184,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath)
httpd_resp_sendstr_chunk(req, "</td><td>"); httpd_resp_sendstr_chunk(req, "</td><td>");
httpd_resp_sendstr_chunk(req, entrysize); httpd_resp_sendstr_chunk(req, entrysize);
httpd_resp_sendstr_chunk(req, "</td><td>"); httpd_resp_sendstr_chunk(req, "</td><td>");
httpd_resp_sendstr_chunk(req, "<form method=\"post\" action=\"/files/delete/"); httpd_resp_sendstr_chunk(req, "<form method=\"post\" action=\"/storage/delete/");
//httpd_resp_sendstr_chunk(req, req->uri); //httpd_resp_sendstr_chunk(req, req->uri);
httpd_resp_sendstr_chunk(req, entry->d_name); httpd_resp_sendstr_chunk(req, entry->d_name);
httpd_resp_sendstr_chunk(req, "\"><button type=\"submit\">Delete</button></form>"); httpd_resp_sendstr_chunk(req, "\"><button type=\"submit\">Delete</button></form>");
@ -418,7 +418,7 @@ esp_err_t upload_post_handler(httpd_req_t *req)
/* Redirect onto root to see the updated file list */ /* Redirect onto root to see the updated file list */
httpd_resp_set_status(req, "303 See Other"); httpd_resp_set_status(req, "303 See Other");
httpd_resp_set_hdr(req, "Location", "/files/"); httpd_resp_set_hdr(req, "Location", "/storage/");
#ifdef CONFIG_EXAMPLE_HTTPD_CONN_CLOSE_HEADER #ifdef CONFIG_EXAMPLE_HTTPD_CONN_CLOSE_HEADER
httpd_resp_set_hdr(req, "Connection", "close"); httpd_resp_set_hdr(req, "Connection", "close");
#endif #endif
@ -466,7 +466,7 @@ esp_err_t delete_post_handler(httpd_req_t *req)
/* Redirect onto root to see the updated file list */ /* Redirect onto root to see the updated file list */
httpd_resp_set_status(req, "303 See Other"); httpd_resp_set_status(req, "303 See Other");
httpd_resp_set_hdr(req, "Location", "/files/"); httpd_resp_set_hdr(req, "Location", "/storage/");
#ifdef CONFIG_EXAMPLE_HTTPD_CONN_CLOSE_HEADER #ifdef CONFIG_EXAMPLE_HTTPD_CONN_CLOSE_HEADER
httpd_resp_set_hdr(req, "Connection", "close"); httpd_resp_set_hdr(req, "Connection", "close");
#endif #endif

View File

@ -173,10 +173,10 @@ static esp_err_t POSTHandler(httpd_req_t *req)
ESP_LOGI(TAG, "POST request handle"); ESP_LOGI(TAG, "POST request handle");
#endif #endif
if (memmem(req->uri, strlen(req->uri), "/files/upload/", sizeof("/files/upload/")-1)) if (memmem(req->uri, strlen(req->uri), "/storage/upload/", sizeof("/storage/upload/")-1))
return upload_post_handler(req); return upload_post_handler(req);
if (memmem(req->uri, strlen(req->uri), "/files/delete/", sizeof("/files/delete/")-1)) if (memmem(req->uri, strlen(req->uri), "/storage/delete/", sizeof("/storage/delete/")-1))
return delete_post_handler(req); return delete_post_handler(req);
char *buf = ((struct file_server_data*) req->user_ctx)->scratch; char *buf = ((struct file_server_data*) req->user_ctx)->scratch;
@ -263,7 +263,7 @@ static esp_err_t GETHandler(httpd_req_t *req)
#endif #endif
//Route to file server GET handler //Route to file server GET handler
if (memmem(req->uri, strlen(req->uri), "/files/", sizeof("/files/") - 1)) if (memmem(req->uri, strlen(req->uri), "/storage/", sizeof("/storage/") - 1))
return download_get_handler(req); return download_get_handler(req);
char filepath[FILE_PATH_MAX]; char filepath[FILE_PATH_MAX];