[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [BP][FIX] Tiki API: Update API responses to exclude raw (BLOB) file data

"Bruno Kambere \(@kambereBr\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6936fbf0a9682_2a17c9d860155@gitlab-sidekiq-low-urgency-cpu-bound-v2-7bf958f4f9-n4jzw.mail>

Bruno Kambere pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
eeedb440 by Bruno Kambere at 2025-12-08T18:15:32+02:00
[BP][FIX] Tiki API: Update API responses to exclude raw (BLOB) file data
---
* [FIX] Tiki API: Update API responses to exclude raw (BLOB) file data
---
* [FIX] Tiki API: Exclude raw file data from responses and return null

* [FIX] Tiki API: Update API responses to exclude raw (BLOB) file data

See merge request tikiwiki/tiki!8777

See merge request tikiwiki/tiki!9192

- - - - -


4 changed files:

- lib/core/Services/File/Controller.php
- templates/api/docs/paths/galleries/files/entity.yaml
- templates/api/docs/paths/galleries/files/update.yaml
- templates/api/docs/paths/galleries/upload.yaml


Changes:

=====================================
lib/core/Services/File/Controller.php
=====================================
@@ -746,10 +746,17 @@ class Services_File_Controller
             throw new Services_Exception_Denied();
         }
 
+        $fileInfo = TikiLib::lib('filegal')->get_file_info($fileId);
+        if (! $fileInfo) {
+            throw new Services_Exception_NotFound(tr('Requested file does not exist'));
+        }
+        // when stored in the database the file contents is here and should not be sent back to the client
+        $fileInfo['data'] = null;
+
         return [
             'title' => tr('File Info'),
             'fileId' => $fileId,
-            'info' => TikiLib::lib('filegal')->get_file_info($fileId)
+            'info' => $fileInfo
         ];
     }
 


=====================================
templates/api/docs/paths/galleries/files/entity.yaml
=====================================
@@ -32,8 +32,6 @@ get:
                 type: integer
               filetype:
                 type: string
-              data:
-                type: object
               user:
                 type: string
               author:


=====================================
templates/api/docs/paths/galleries/files/update.yaml
=====================================
@@ -11,10 +11,13 @@ post:
   requestBody:
     required: true
     content:
-      application/x-www-form-urlencoded:
+      multipart/form-data:
         schema:
           type: object
           properties:
+            data:
+              type: file
+              description: file path to upload. If omitted, the current file will remain unchanged.
             user:
               type: string
               description: The user who uploaded the file
@@ -27,23 +30,6 @@ post:
             description:
               type: string
               description: The description of the file
-      multipart/form-data:
-        schema:
-          type: object
-          required:
-            - data
-          properties:
-            data:
-              type: string
-              description: file path
-            user:
-              type: string
-            title:
-              type: string
-            name:
-              type: string
-            description:
-              type: string
   responses:
     '200':
       description: update file response
@@ -69,7 +55,77 @@ post:
               md5sum:
                 type: string
               ticket:
+                type: string
+              syntax:
+                type: string
+              info:
                 type: object
+                properties:
+                  fileId:
+                    type: integer
+                  galleryId:
+                    type: integer
+                  name:
+                    type: string
+                  description:
+                    type: string
+                  created:
+                    type: integer
+                  filename:
+                    type: string
+                  filesize:
+                    type: integer
+                  filetype:
+                    type: string
+                  user:
+                    type: string
+                  author:
+                    type: string
+                  hits:
+                    type: integer
+                  maxhits:
+                    type: integer
+                  lastDownload:
+                    type: integer
+                  votes:
+                    type: integer
+                  points:
+                    type: string
+                  path:
+                    type: string
+                    nullable: true
+                  reference_url:
+                    type: string
+                  is_reference:
+                    type: string
+                  hash:
+                    type: string
+                  search_data:
+                    type: string
+                  metadata:
+                    type: string
+                    description: JSON-encoded metadata string
+                  lastModif:
+                    type: integer
+                  lastModifUser:
+                    type: string
+                  lockedby:
+                    type: string
+                  comment:
+                    type: string
+                  archiveId:
+                    type: integer
+                  deleteAfter:
+                    type: integer
+                  ocr_state:
+                    type: string
+                    nullable: true
+                  ocr_lang:
+                    type: string
+                    nullable: true
+                  ocr_data:
+                    type: string
+                    nullable: true
     '403':
       description: forbidden
       content:


=====================================
templates/api/docs/paths/galleries/upload.yaml
=====================================
@@ -56,7 +56,77 @@ post:
               md5sum:
                 type: string
               ticket:
+                type: string
+              syntax:
+                type: string
+              info:
                 type: object
+                properties:
+                  fileId:
+                    type: integer
+                  galleryId:
+                    type: integer
+                  name:
+                    type: string
+                  description:
+                    type: string
+                  created:
+                    type: integer
+                  filename:
+                    type: string
+                  filesize:
+                    type: integer
+                  filetype:
+                    type: string
+                  user:
+                    type: string
+                  author:
+                    type: string
+                  hits:
+                    type: integer
+                  maxhits:
+                    type: integer
+                  lastDownload:
+                    type: integer
+                  votes:
+                    type: integer
+                  points:
+                    type: string
+                  path:
+                    type: string
+                    nullable: true
+                  reference_url:
+                    type: string
+                  is_reference:
+                    type: string
+                  hash:
+                    type: string
+                  search_data:
+                    type: string
+                  metadata:
+                    type: string
+                    description: JSON-encoded metadata string
+                  lastModif:
+                    type: integer
+                  lastModifUser:
+                    type: string
+                  lockedby:
+                    type: string
+                  comment:
+                    type: string
+                  archiveId:
+                    type: integer
+                  deleteAfter:
+                    type: integer
+                  ocr_state:
+                    type: string
+                    nullable: true
+                  ocr_lang:
+                    type: string
+                    nullable: true
+                  ocr_data:
+                    type: string
+                    nullable: true
     '403':
       description: forbidden
       content:



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/eeedb4408e52e83d7788b280cd185e2c8337ea4a

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/eeedb4408e52e83d7788b280cd185e2c8337ea4a
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.