|
|
@@ -204,7 +204,12 @@ export class UploaderService {
|
|
|
maxBytes: number,
|
|
|
rootPath: string,
|
|
|
): Promise<string> {
|
|
|
- let source = file.file as NodeJS.ReadableStream | undefined;
|
|
|
+ let source = (file as any)?.file as NodeJS.ReadableStream | undefined;
|
|
|
+ if (!source) {
|
|
|
+ if (Buffer.isBuffer(file) || file instanceof Uint8Array) {
|
|
|
+ source = Readable.from(file);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!source) {
|
|
|
const maybeBuffer =
|
|
|
(file as any).buffer ??
|
|
|
@@ -221,20 +226,6 @@ export class UploaderService {
|
|
|
}
|
|
|
}
|
|
|
if (!source) {
|
|
|
- const fileAny = file as any;
|
|
|
- const debug = {
|
|
|
- hasFile: !!file,
|
|
|
- fileKeys: file ? Object.keys(fileAny) : [],
|
|
|
- fileTypes: {
|
|
|
- file: typeof fileAny?.file,
|
|
|
- buffer: typeof fileAny?.buffer,
|
|
|
- value: typeof fileAny?.value,
|
|
|
- data: typeof fileAny?.data,
|
|
|
- toBuffer: typeof fileAny?.toBuffer,
|
|
|
- },
|
|
|
- };
|
|
|
- // eslint-disable-next-line no-console
|
|
|
- console.warn('Uploader: missing stream source', debug);
|
|
|
throw new BadRequestException('Upload stream is missing');
|
|
|
}
|
|
|
|