41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import * as plugins from './smartbucket.plugins';
|
|
import { Bucket } from './smartbucket.classes.bucket';
|
|
|
|
export interface ISmartBucketConfig {
|
|
endpoint: string;
|
|
accessKey: string;
|
|
accessSecret: string;
|
|
}
|
|
|
|
export class SmartBucket {
|
|
public config: ISmartBucketConfig;
|
|
|
|
public minioClient: plugins.minio.Client;
|
|
|
|
/**
|
|
* the constructor of SmartBucket
|
|
*/
|
|
constructor(configArg: ISmartBucketConfig) {
|
|
this.config = configArg;
|
|
this.minioClient = new plugins.minio.Client({
|
|
endPoint: this.config.endpoint,
|
|
port: 443,
|
|
useSSL: true,
|
|
accessKey: this.config.accessKey,
|
|
secretKey: this.config.accessSecret
|
|
});
|
|
}
|
|
|
|
public async createBucket(bucketName: string) {
|
|
await this.minioClient.makeBucket(bucketName, 'ams3').catch(e => console.log(e));
|
|
}
|
|
|
|
public async removeBucket(bucketName: string) {
|
|
await this.minioClient.removeBucket(bucketName).catch(e => console.log(e));
|
|
}
|
|
|
|
public async getBucket(bucketName: string) {
|
|
return Bucket.getFromName(this, bucketName);
|
|
}
|
|
}
|