From b9d082f07fd5f0610f77823c242aba2f30348bec Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 19 Jun 2020 00:42:26 +0000 Subject: [PATCH] fix(core): update --- ts/smartbucket.classes.bucket.ts | 15 ++++++++------- ts/smartbucket.classes.directory.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ts/smartbucket.classes.bucket.ts b/ts/smartbucket.classes.bucket.ts index 7442665..655939a 100644 --- a/ts/smartbucket.classes.bucket.ts +++ b/ts/smartbucket.classes.bucket.ts @@ -65,11 +65,13 @@ export class Bucket { */ public async fastGet(pathArg: string) { const done = plugins.smartpromise.defer(); - let completeFile: string = ''; + let completeFile: Buffer; const replaySubject = await this.fastGetStream(pathArg); replaySubject.subscribe( - chunkString => { - completeFile += chunkString; + chunk => { + if (completeFile) { + completeFile = Buffer.concat([completeFile, chunk]); + } }, err => { console.log(err); @@ -82,15 +84,14 @@ export class Bucket { return completeFile; } - public async fastGetStream(pathArg: string): Promise> { + public async fastGetStream(pathArg: string): Promise> { const fileStream = await this.smartbucketRef.minioClient .getObject(this.name, pathArg) .catch(e => console.log(e)); - const replaySubject = new plugins.smartrx.rxjs.ReplaySubject(); + const replaySubject = new plugins.smartrx.rxjs.ReplaySubject(); const duplexStream = plugins.streamfunction.createDuplexStream( async chunk => { - const chunkString = chunk.toString(); - replaySubject.next(chunkString); + replaySubject.next(chunk); return chunk; }, async cb => { diff --git a/ts/smartbucket.classes.directory.ts b/ts/smartbucket.classes.directory.ts index 7b2c580..c9c2efe 100644 --- a/ts/smartbucket.classes.directory.ts +++ b/ts/smartbucket.classes.directory.ts @@ -184,7 +184,7 @@ export class Directory { return result; } - public async fastGetStream(pathArg: string): Promise> { + public async fastGetStream(pathArg: string): Promise> { const path = plugins.path.join(this.getBasePath(), pathArg); const result = await this.bucketRef.fastGetStream(path); return result;