Prechádzať zdrojové kódy

refactor handling string input

Dave 1 mesiac pred
rodič
commit
9ff2606205

+ 0 - 10
apps/box-mgnt-api/src/mgnt-backend/feature/uploader/uploader.controller.ts

@@ -60,16 +60,6 @@ export class UploaderController {
     let mpFile: MultipartFile | undefined = Array.isArray(bodyFile)
       ? bodyFile[0]
       : bodyFile;
-    // eslint-disable-next-line no-console
-    console.warn('Uploader: file debug', {
-      isMultipart: typeof reqAny.isMultipart === 'function' ? reqAny.isMultipart() : false,
-      bodyFileType: typeof bodyFile,
-      bodyFileIsArray: Array.isArray(bodyFile),
-      bodyFileLength: bodyFile?.length,
-      bodyFileKeys: bodyFile ? Object.keys(bodyFile).slice(0, 8) : [],
-      mpFileType: typeof mpFile,
-      mpFileKeys: mpFile ? Object.keys(mpFile).slice(0, 8) : [],
-    });
     if (!mpFile && reqAny.isMultipart?.()) {
       mpFile = await reqAny.file();
     }

+ 1 - 0
apps/box-mgnt-api/src/mgnt-backend/feature/uploader/uploader.service.ts

@@ -209,6 +209,7 @@ export class UploaderService {
       if (Buffer.isBuffer(value)) return value;
       if (value instanceof Uint8Array) return Buffer.from(value);
       if (Array.isArray(value)) return Buffer.from(value);
+      if (typeof value === 'string') return Buffer.from(value, 'binary');
       if (typeof value === 'object') {
         try {
           return Buffer.from(value as ArrayLike<number>);