@@ -51,7 +51,7 @@ async function getToken(permission, forceRenewal) {
5151async function apiAuthModify ( apiKey , permission , modifier ) {
5252 const apiUrl = './api/auth/modify' ;
5353 const reqPerm = 'PERM_API_MOD' ;
54-
54+
5555 let token ;
5656
5757 try {
@@ -88,7 +88,7 @@ async function apiAuthModify(apiKey, permission, modifier) {
8888async function apiAuthFriendlyName ( apiKey , newName ) {
8989 const apiUrl = './api/auth/friendlyname' ;
9090 const reqPerm = 'PERM_API_MOD' ;
91-
91+
9292 let token ;
9393
9494 try {
@@ -124,7 +124,7 @@ async function apiAuthFriendlyName(apiKey, newName) {
124124async function apiAuthDelete ( apiKey ) {
125125 const apiUrl = './api/auth/delete' ;
126126 const reqPerm = 'PERM_API_MOD' ;
127-
127+
128128 let token ;
129129
130130 try {
@@ -158,7 +158,7 @@ async function apiAuthDelete(apiKey) {
158158async function apiAuthCreate ( ) {
159159 const apiUrl = './api/auth/create' ;
160160 const reqPerm = 'PERM_API_MOD' ;
161-
161+
162162 let token ;
163163
164164 try {
@@ -199,7 +199,7 @@ async function apiAuthCreate() {
199199async function apiChunkComplete ( uuid , filename , filesize , realsize , contenttype , allowedDownloads , expiryDays , password , isE2E , nonblocking ) {
200200 const apiUrl = './api/chunk/complete' ;
201201 const reqPerm = 'PERM_UPLOAD' ;
202-
202+
203203 let token ;
204204
205205 try {
@@ -258,7 +258,7 @@ async function apiChunkComplete(uuid, filename, filesize, realsize, contenttype,
258258async function apiFilesReplace ( id , newId ) {
259259 const apiUrl = './api/files/replace' ;
260260 const reqPerm = 'PERM_REPLACE' ;
261-
261+
262262 let token ;
263263
264264 try {
@@ -295,7 +295,7 @@ async function apiFilesReplace(id, newId) {
295295async function apiFilesListById ( fileId ) {
296296 const apiUrl = './api/files/list/' + fileId ;
297297 const reqPerm = 'PERM_VIEW' ;
298-
298+
299299 let token ;
300300
301301 try {
@@ -304,7 +304,7 @@ async function apiFilesListById(fileId) {
304304 console . error ( "Unable to gain permission token:" , error ) ;
305305 throw error ;
306306 }
307-
307+
308308 const requestOptions = {
309309 method : 'GET' ,
310310 headers : {
@@ -331,7 +331,7 @@ async function apiFilesListById(fileId) {
331331async function apiFilesModify ( id , allowedDownloads , expiry , password , originalPw ) {
332332 const apiUrl = './api/files/modify' ;
333333 const reqPerm = 'PERM_EDIT' ;
334-
334+
335335 let token ;
336336
337337 try {
@@ -371,7 +371,7 @@ async function apiFilesModify(id, allowedDownloads, expiry, password, originalPw
371371async function apiFilesDelete ( id , delay ) {
372372 const apiUrl = './api/files/delete' ;
373373 const reqPerm = 'PERM_DELETE' ;
374-
374+
375375 let token ;
376376
377377 try {
@@ -406,7 +406,7 @@ async function apiFilesDelete(id, delay) {
406406async function apiFilesRestore ( id ) {
407407 const apiUrl = './api/files/restore' ;
408408 const reqPerm = 'PERM_DELETE' ;
409-
409+
410410 let token ;
411411
412412 try {
@@ -446,7 +446,7 @@ async function apiFilesRestore(id) {
446446async function apiUserCreate ( userName ) {
447447 const apiUrl = './api/user/create' ;
448448 const reqPerm = 'PERM_MANAGE_USERS' ;
449-
449+
450450 let token ;
451451
452452 try {
@@ -486,7 +486,7 @@ async function apiUserCreate(userName) {
486486async function apiUserModify ( userId , permission , modifier ) {
487487 const apiUrl = './api/user/modify' ;
488488 const reqPerm = 'PERM_MANAGE_USERS' ;
489-
489+
490490 let token ;
491491
492492 try {
@@ -523,7 +523,7 @@ async function apiUserModify(userId, permission, modifier) {
523523async function apiUserChangeRank ( userId , newRank ) {
524524 const apiUrl = './api/user/changeRank' ;
525525 const reqPerm = 'PERM_MANAGE_USERS' ;
526-
526+
527527 let token ;
528528
529529 try {
@@ -558,7 +558,7 @@ async function apiUserChangeRank(userId, newRank) {
558558async function apiUserDelete ( id , deleteFiles ) {
559559 const apiUrl = './api/user/delete' ;
560560 const reqPerm = 'PERM_MANAGE_USERS' ;
561-
561+
562562 let token ;
563563
564564 try {
@@ -594,7 +594,7 @@ async function apiUserDelete(id, deleteFiles) {
594594async function apiUserResetPassword ( id , generatePw ) {
595595 const apiUrl = './api/user/resetPassword' ;
596596 const reqPerm = 'PERM_MANAGE_USERS' ;
597-
597+
598598 let token ;
599599
600600 try {
@@ -632,7 +632,7 @@ async function apiUserResetPassword(id, generatePw) {
632632async function apiLogsDelete ( timestamp ) {
633633 const apiUrl = './api/logs/delete' ;
634634 const reqPerm = 'PERM_MANAGE_LOGS' ;
635-
635+
636636 let token ;
637637
638638 try {
@@ -668,7 +668,7 @@ async function apiLogsDelete(timestamp) {
668668async function apiE2eGet ( ) {
669669 const apiUrl = './api/e2e/get' ;
670670 const reqPerm = 'PERM_UPLOAD' ;
671-
671+
672672 let token ;
673673
674674 try {
@@ -703,7 +703,7 @@ async function apiE2eGet() {
703703async function apiE2eStore ( content ) {
704704 const apiUrl = './api/e2e/set' ;
705705 const reqPerm = 'PERM_UPLOAD' ;
706-
706+
707707 let token ;
708708
709709 try {
@@ -735,10 +735,13 @@ async function apiE2eStore(content) {
735735 }
736736}
737737
738+
739+ // Upload Requests
740+
738741async function apiURequestDelete ( id ) {
739742 const apiUrl = './api/uploadrequest/delete' ;
740743 const reqPerm = 'PERM_MANAGE_FILE_REQUESTS' ;
741-
744+
742745 let token ;
743746
744747 try {
@@ -767,3 +770,44 @@ async function apiURequestDelete(id) {
767770 throw error ;
768771 }
769772}
773+
774+
775+
776+ async function apiURequestSave ( id , name , maxfiles , maxsize , expiry ) {
777+ const apiUrl = './api/uploadrequest/save' ;
778+ const reqPerm = 'PERM_MANAGE_FILE_REQUESTS' ;
779+
780+ let token ;
781+
782+ try {
783+ token = await getToken ( reqPerm , false ) ;
784+ } catch ( error ) {
785+ console . error ( "Unable to gain permission token:" , error ) ;
786+ throw error ;
787+ }
788+
789+ const requestOptions = {
790+ method : 'POST' ,
791+ headers : {
792+ 'Content-Type' : 'application/json' ,
793+ 'apikey' : token ,
794+ 'id' : id ,
795+ 'name' : 'base64:' + Base64 . encode ( name ) ,
796+ 'expiry' : expiry ,
797+ 'maxfiles' : maxfiles ,
798+ 'maxsize' : maxsize
799+ } ,
800+ } ;
801+
802+ try {
803+ const response = await fetch ( apiUrl , requestOptions ) ;
804+ if ( ! response . ok ) {
805+ throw new Error ( `Request failed with status: ${ response . status } ` ) ;
806+ }
807+ const data = await response . json ( ) ;
808+ return data ;
809+ } catch ( error ) {
810+ console . error ( "Error in apiURequestDelete:" , error ) ;
811+ throw error ;
812+ }
813+ }
0 commit comments