fix(core): update
This commit is contained in:
parent
4819dd0bc5
commit
b9d082f07f
@ -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<plugins.smartrx.rxjs.ReplaySubject<string>> {
|
||||
public async fastGetStream(pathArg: string): Promise<plugins.smartrx.rxjs.ReplaySubject<Buffer>> {
|
||||
const fileStream = await this.smartbucketRef.minioClient
|
||||
.getObject(this.name, pathArg)
|
||||
.catch(e => console.log(e));
|
||||
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject<string>();
|
||||
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject<Buffer>();
|
||||
const duplexStream = plugins.streamfunction.createDuplexStream<Buffer, Buffer>(
|
||||
async chunk => {
|
||||
const chunkString = chunk.toString();
|
||||
replaySubject.next(chunkString);
|
||||
replaySubject.next(chunk);
|
||||
return chunk;
|
||||
},
|
||||
async cb => {
|
||||
|
@ -184,7 +184,7 @@ export class Directory {
|
||||
return result;
|
||||
}
|
||||
|
||||
public async fastGetStream(pathArg: string): Promise<plugins.smartrx.rxjs.ReplaySubject<string>> {
|
||||
public async fastGetStream(pathArg: string): Promise<plugins.smartrx.rxjs.ReplaySubject<Buffer>> {
|
||||
const path = plugins.path.join(this.getBasePath(), pathArg);
|
||||
const result = await this.bucketRef.fastGetStream(path);
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user