42 lines
1.0 KiB
TypeScript
42 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(bucketNameArg: string) {
|
|
const bucket = await Bucket.createBucketByName(this, bucketNameArg);
|
|
return bucket;
|
|
}
|
|
|
|
public async removeBucket(bucketName: string) {
|
|
await Bucket.removeBucketByName(this, bucketName);
|
|
}
|
|
|
|
public async getBucketByName(bucketName: string) {
|
|
return Bucket.getBucketByName(this, bucketName);
|
|
}
|
|
}
|