upload: change REST path from /ctdl/a/upload/ to /ctdl/p/
authorArt Cancro <art.cancro@tierpoint.com>
Tue, 3 Oct 2023 18:35:01 +0000 (14:35 -0400)
committerArt Cancro <art.cancro@tierpoint.com>
Tue, 3 Oct 2023 18:35:01 +0000 (14:35 -0400)
webcit-ng/api.txt
webcit-ng/server/admin_functions.c
webcit-ng/server/request.c
webcit-ng/server/upload.c
webcit-ng/server/webcit.h
webcit-ng/static/js/upload.js

index 5336667486fea79312d0878b526cec50267c2860..992a30f3e2c7fd9c4f17d33a13515616a55d16dc 100644 (file)
@@ -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/<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)
+POST            /ctdl/p/                           Handler for uploading attachments and other file items
index 61afb48b122e06291aa8a4efe3681112d537fc18..7a585e49e332630ae0da94bb461db790009e8604 100644 (file)
@@ -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
 }
index 6622c28b108f70a54ec904019b91ad907ba86d54..4b8b3b1d1363a80d2e995e51bbbd0ebf961ddd08 100644 (file)
@@ -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);
        }
index 1d7fbf95676ae64710160d03b7753ccb4a3acd41..9fd363838e3cf6ff3d0a20b5e9cf7630385e2711 100644 (file)
@@ -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
+}
index c9ce2913293412f5d7534a27cabc4c25fb127255..7cc853a4de93a013f8a8aba908c59ac2cad5dcc2 100644 (file)
@@ -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);
index c62d1c4f212b2edb9db7365e719d3d4add82167a..39b9d018728861c56630ee84c234aff37003eab8 100644 (file)
@@ -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
+}