|
|
@@ -316,17 +316,22 @@ export class VideoMediaController {
|
|
|
|
|
|
// fastify multipart
|
|
|
const reqAny = req as any;
|
|
|
- const bodyFile = reqAny.body?.file;
|
|
|
- let mpFile = Array.isArray(bodyFile) ? bodyFile[0] : bodyFile;
|
|
|
- if (!mpFile && reqAny.isMultipart?.()) {
|
|
|
- mpFile = await reqAny.file();
|
|
|
+ let buf: Buffer | undefined;
|
|
|
+
|
|
|
+ if (reqAny.isMultipart?.() && typeof reqAny.file === 'function') {
|
|
|
+ const part = await reqAny.file();
|
|
|
+ buf = await getBuffer(part);
|
|
|
}
|
|
|
|
|
|
- if (!mpFile) {
|
|
|
- throw new BadRequestException('No file uploaded');
|
|
|
+ if (!buf) {
|
|
|
+ const bodyFile = reqAny.body?.file;
|
|
|
+ const mpFile = Array.isArray(bodyFile) ? bodyFile[0] : bodyFile;
|
|
|
+ buf = await getBuffer(mpFile);
|
|
|
}
|
|
|
|
|
|
- const buf = await getBuffer(mpFile);
|
|
|
+ if (!buf) {
|
|
|
+ throw new BadRequestException('No file uploaded');
|
|
|
+ }
|
|
|
|
|
|
if (!buf?.length) {
|
|
|
throw new BadRequestException('Empty file');
|