Skip to content

Commit

Permalink
fix(core): Fix stream not being instance of ReadStream (#1238)
Browse files Browse the repository at this point in the history
The stream will not be recognized as ReadStream if used createReadStream from the regular FS package. 
This will fix it.
  • Loading branch information
HarunKilic authored Nov 26, 2021
1 parent c56b85f commit 5ee371d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/service/services/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ID, PaginatedList, Type } from '@vendure/common/lib/shared-types';
import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
import { unique } from '@vendure/common/lib/unique';
import { ReadStream } from 'fs-extra';
import { ReadStream as FSReadStream } from 'fs';
import mime from 'mime-types';
import path from 'path';
import { Readable, Stream } from 'stream';
Expand Down Expand Up @@ -393,7 +394,7 @@ export class AssetService {
stream: ReadStream | Readable,
maybeFilePath?: string,
): Promise<CreateAssetResult> {
const filePath = stream instanceof ReadStream ? stream.path : maybeFilePath;
const filePath = stream instanceof ReadStream || stream instanceof FSReadStream ? stream.path : maybeFilePath;
if (typeof filePath === 'string') {
const filename = path.basename(filePath);
const mimetype = mime.lookup(filename) || 'application/octet-stream';
Expand Down

0 comments on commit 5ee371d

Please sign in to comment.