From: Art Cancro Date: Tue, 3 Oct 2023 18:35:01 +0000 (-0400) Subject: upload: change REST path from /ctdl/a/upload/ to /ctdl/p/ X-Git-Tag: v997~130 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1a061e3dcbc2789e86224e3a67d94608bd20deb7 upload: change REST path from /ctdl/a/upload/ to /ctdl/p/ --- diff --git a/webcit-ng/api.txt b/webcit-ng/api.txt index 533666748..992a30f3e 100644 --- a/webcit-ng/api.txt +++ b/webcit-ng/api.txt @@ -31,7 +31,7 @@ GET /ctdl/c/info Returns a JSON representation POST /ctdl/a/login Send it a your credentials and it will log you in GET /ctdl/a/whoami GET /ctdl/a/biff Check for new mail -POST /ctdl/a/upload Handler for uploading attachments and other file items GET /ctdl/u//userpic Returns an image containing the photo/avatar of the specified user GET /ctdl/s/ Static content (html, css, js, images...) GET /.well-known/ Static content (RFC5785 compliant paths) +POST /ctdl/p/ Handler for uploading attachments and other file items diff --git a/webcit-ng/server/admin_functions.c b/webcit-ng/server/admin_functions.c index 61afb48b1..7a585e49e 100644 --- a/webcit-ng/server/admin_functions.c +++ b/webcit-ng/server/admin_functions.c @@ -1,6 +1,6 @@ // Admin functions // -// Copyright (c) 1996-2022 by the citadel.org team +// Copyright (c) 1996-2023 by the citadel.org team // // This program is open source software. Use, duplication, or // disclosure are subject to the GNU General Public License v3. @@ -120,10 +120,6 @@ void ctdl_a(struct http_transaction *h, struct ctdlsession *c) { biff(h, c); return; } - if (!strcasecmp(h->url, "/ctdl/a/upload")) { // upload files - upload_files(h, c); - return; - } do_404(h); // unknown } diff --git a/webcit-ng/server/request.c b/webcit-ng/server/request.c index 6622c28b1..4b8b3b1d1 100644 --- a/webcit-ng/server/request.c +++ b/webcit-ng/server/request.c @@ -162,6 +162,9 @@ void perform_request(struct http_transaction *h) { case 'u': // /ctdl/u/ == RESTful path to users ctdl_u(h, c); break; + case 'p': // /ctdl/p/ == RESTful path to upload functions + ctdl_p(h, c); + break; default: do_404(h); } diff --git a/webcit-ng/server/upload.c b/webcit-ng/server/upload.c index 1d7fbf956..9fd363838 100644 --- a/webcit-ng/server/upload.c +++ b/webcit-ng/server/upload.c @@ -1,6 +1,6 @@ // Upload handler // -// Copyright (c) 1996-2022 by the citadel.org team +// Copyright (c) 1996-2023 by the citadel.org team // // This program is open source software. Use, duplication, or // disclosure are subject to the GNU General Public License v3. @@ -70,4 +70,15 @@ void upload_files(struct http_transaction *h, struct ctdlsession *c) { h->response_string = strdup("OK"); h->response_body_length = StrLength(sj); h->response_body = SmashStrBuf(&sj); -} \ No newline at end of file +} + + +// Dispatcher for paths starting with /ctdl/p/ +void ctdl_p(struct http_transaction *h, struct ctdlsession *c) { + if (!strcasecmp(h->url, "/ctdl/p/")) { // upload files + upload_files(h, c); + return; + } + + do_404(h); // unknown +} diff --git a/webcit-ng/server/webcit.h b/webcit-ng/server/webcit.h index c9ce29132..7cc853a4d 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -138,6 +138,7 @@ void ctdl_a(struct http_transaction *, struct ctdlsession *); void ctdl_f(struct http_transaction *, struct ctdlsession *); void ctdl_r(struct http_transaction *, struct ctdlsession *); void ctdl_u(struct http_transaction *, struct ctdlsession *); +void ctdl_p(struct http_transaction *, struct ctdlsession *); struct ctdlsession *connect_to_citadel(struct http_transaction *); void disconnect_from_citadel(struct ctdlsession *); char *header_val(struct http_transaction *h, char *requested_header); diff --git a/webcit-ng/static/js/upload.js b/webcit-ng/static/js/upload.js index c62d1c4f2..39b9d0187 100644 --- a/webcit-ng/static/js/upload.js +++ b/webcit-ng/static/js/upload.js @@ -66,7 +66,7 @@ function handle_upload_files(files) { function upload_file(file) { - var url = '/ctdl/a/upload'; + var url = '/ctdl/p/'; var xhr = new XMLHttpRequest(); var formData = new FormData(); xhr.open('POST', url, true); @@ -145,4 +145,4 @@ function flush_uploads() { document.getElementById('ctdl-upload').style.display='none'; // FIXME tell the server to delete the files uploads=[]; -} \ No newline at end of file +}