fix(core): update
This commit is contained in:
		| @@ -37,7 +37,43 @@ export class Bucket { | ||||
|   /** | ||||
|    * store file | ||||
|    */ | ||||
|   public store(pathArg: string, fileContent: string) { | ||||
|      | ||||
|   public async store(pathArg: string, fileContent: string) { | ||||
|     const streamIntake = new plugins.streamfunction.Intake(); | ||||
|     const putPromise = this.smartbucketRef.minioClient.putObject(this.name, pathArg, streamIntake.getReadable()).catch(e => console.log(e)); | ||||
|     streamIntake.pushData(fileContent); | ||||
|     streamIntake.signalEnd(); | ||||
|     await putPromise; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * get file | ||||
|    */ | ||||
|   public async get(pathArg: string) { | ||||
|     const done = plugins.smartpromise.defer(); | ||||
|     const fileStream = await this.smartbucketRef.minioClient.getObject(this.name, pathArg).catch(e => console.log(e)); | ||||
|     let completeFile: string = ''; | ||||
|     const duplexStream = plugins.streamfunction.createDuplexStream<Buffer, Buffer>(async (chunk) => { | ||||
|       const chunkString = chunk.toString(); | ||||
|       completeFile += chunkString; | ||||
|       return chunk; | ||||
|     }, async (cb) => { | ||||
|       done.resolve(); | ||||
|       return Buffer.from(''); | ||||
|     }); | ||||
|  | ||||
|     if (!fileStream) { | ||||
|       return null; | ||||
|     } | ||||
|  | ||||
|     fileStream.pipe(duplexStream); | ||||
|     await done.promise; | ||||
|     return completeFile; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * removeObject | ||||
|    */ | ||||
|   public async remove (pathArg: string) { | ||||
|     await this.smartbucketRef.minioClient.removeObject(this.name, pathArg); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| import * as smartpromise from '@pushrocks/smartpromise'; | ||||
| import * as streamfunction from '@pushrocks/streamfunction'; | ||||
|  | ||||
| export { smartpromise }; | ||||
| export { smartpromise, streamfunction }; | ||||
|  | ||||
| // third party scope | ||||
| import * as minio from 'minio'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user