Sfoglia il codice sorgente

refactor: enhance VideoMediaController to support multipart file handling in buffer retrieval

Dave 3 settimane fa
parent
commit
291c7283c6

+ 9 - 0
apps/box-mgnt-api/src/mgnt-backend/feature/video-media/video-media.controller.ts

@@ -323,6 +323,15 @@ export class VideoMediaController {
       buf = await getBuffer(part);
     }
 
+    if (!buf && reqAny.isMultipart?.() && typeof reqAny.parts === 'function') {
+      for await (const part of reqAny.parts()) {
+        if (part?.type === 'file' && part?.fieldname === 'file') {
+          buf = await getBuffer(part);
+          break;
+        }
+      }
+    }
+
     if (!buf) {
       const bodyFile = reqAny.body?.file;
       const mpFile = Array.isArray(bodyFile) ? bodyFile[0] : bodyFile;