diff --git a/ts/smartbucket.classes.bucket.ts b/ts/smartbucket.classes.bucket.ts index e7f220d..8140c36 100644 --- a/ts/smartbucket.classes.bucket.ts +++ b/ts/smartbucket.classes.bucket.ts @@ -50,7 +50,7 @@ export class Bucket { /** * store file */ - public async fastStore(pathArg: string, fileContent: string) { + public async fastStore(pathArg: string, fileContent: string | Buffer): Promise { const streamIntake = new plugins.streamfunction.Intake(); const putPromise = this.smartbucketRef.minioClient .putObject(this.name, pathArg, streamIntake.getReadable()) @@ -63,11 +63,11 @@ export class Bucket { /** * get file */ - public async fastGet(pathArg: string) { + public async fastGet(pathArg: string): Promise { const done = plugins.smartpromise.defer(); let completeFile: Buffer; const replaySubject = await this.fastGetStream(pathArg); - replaySubject.subscribe( + const subscription = replaySubject.subscribe( (chunk) => { if (completeFile) { completeFile = Buffer.concat([completeFile, chunk]); @@ -78,6 +78,7 @@ export class Bucket { }, () => { done.resolve(); + subscription.unsubscribe(); } ); await done.promise;