From: Art Cancro Date: Tue, 26 Sep 2023 02:13:59 +0000 (-0400) Subject: upload.c: stub function for accepting uploads X-Git-Tag: v995~8 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=98de4fca2d3592ee02e3865035bb0fde9979c41b;p=citadel.git upload.c: stub function for accepting uploads --- diff --git a/webcit-ng/README.md b/webcit-ng/README.md index 442d40e31..95ab1f80e 100644 --- a/webcit-ng/README.md +++ b/webcit-ng/README.md @@ -20,7 +20,7 @@ REST format URLs will generally take the form of: /ctdl/objectClass/[container/]object[/operation] ## We are using -* libcitadel for information about the Citadel server, some string handling, and the JSON encoder +* libcitadel for Citadel server tooling, string handling, JSON encoder, MIME parser * Expat for DAV handling * OpenSSL for TLS * FontAwesome for icons diff --git a/webcit-ng/api.txt b/webcit-ng/api.txt index 3182f4c20..97ae9c0d5 100644 --- a/webcit-ng/api.txt +++ b/webcit-ng/api.txt @@ -30,6 +30,8 @@ GET /ctdl/r/ROOMNAME/slrp Set the "Last Read Pointer" for GET /ctdl/c/info Returns a JSON representation of the output of an INFO server command 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/USERNAME/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) diff --git a/webcit-ng/server/admin_functions.c b/webcit-ng/server/admin_functions.c index 1d193cf9b..61afb48b1 100644 --- a/webcit-ng/server/admin_functions.c +++ b/webcit-ng/server/admin_functions.c @@ -120,6 +120,10 @@ 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/webcit.h b/webcit-ng/server/webcit.h index 1304100dd..c9ce29132 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -168,3 +168,4 @@ void ctdl_printf(struct ctdlsession *ctdl, const char *format,...); int webcit_tcp_server(const char *ip_addr, int port_number, int queue_len); void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf); void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, long msgnum); +void upload_files(struct http_transaction *h, struct ctdlsession *c); diff --git a/webcit-ng/static/js/view_mail.js b/webcit-ng/static/js/view_mail.js index 2e05f7d6d..819a9e397 100644 --- a/webcit-ng/static/js/view_mail.js +++ b/webcit-ng/static/js/view_mail.js @@ -595,7 +595,7 @@ function handleFiles(files) { function uploadFile(file) { - var url = '/ctdl/zzz/attach_it;' + var url = '/ctdl/a/upload'; var xhr = new XMLHttpRequest(); var formData = new FormData(); xhr.open('POST', url, true);