Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
b61a86f029 | |||
b9d082f07f |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartbucket",
|
"name": "@pushrocks/smartbucket",
|
||||||
"version": "1.0.29",
|
"version": "1.0.30",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartbucket",
|
"name": "@pushrocks/smartbucket",
|
||||||
"version": "1.0.29",
|
"version": "1.0.30",
|
||||||
"description": "simple cloud independent object storage",
|
"description": "simple cloud independent object storage",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
@ -65,11 +65,13 @@ export class Bucket {
|
|||||||
*/
|
*/
|
||||||
public async fastGet(pathArg: string) {
|
public async fastGet(pathArg: string) {
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
let completeFile: string = '';
|
let completeFile: Buffer;
|
||||||
const replaySubject = await this.fastGetStream(pathArg);
|
const replaySubject = await this.fastGetStream(pathArg);
|
||||||
replaySubject.subscribe(
|
replaySubject.subscribe(
|
||||||
chunkString => {
|
chunk => {
|
||||||
completeFile += chunkString;
|
if (completeFile) {
|
||||||
|
completeFile = Buffer.concat([completeFile, chunk]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@ -82,15 +84,14 @@ export class Bucket {
|
|||||||
return completeFile;
|
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
|
const fileStream = await this.smartbucketRef.minioClient
|
||||||
.getObject(this.name, pathArg)
|
.getObject(this.name, pathArg)
|
||||||
.catch(e => console.log(e));
|
.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>(
|
const duplexStream = plugins.streamfunction.createDuplexStream<Buffer, Buffer>(
|
||||||
async chunk => {
|
async chunk => {
|
||||||
const chunkString = chunk.toString();
|
replaySubject.next(chunk);
|
||||||
replaySubject.next(chunkString);
|
|
||||||
return chunk;
|
return chunk;
|
||||||
},
|
},
|
||||||
async cb => {
|
async cb => {
|
||||||
|
@ -184,7 +184,7 @@ export class Directory {
|
|||||||
return result;
|
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 path = plugins.path.join(this.getBasePath(), pathArg);
|
||||||
const result = await this.bucketRef.fastGetStream(path);
|
const result = await this.bucketRef.fastGetStream(path);
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user