2018-09-14 16:07:20 +00:00
|
|
|
import * as plugins from './smartbucket.plugins';
|
2019-10-15 12:16:28 +00:00
|
|
|
import { Bucket } from './smartbucket.classes.bucket';
|
2018-09-14 16:07:20 +00:00
|
|
|
|
|
|
|
export interface ISmartBucketConfig {
|
2019-10-15 12:16:28 +00:00
|
|
|
endpoint: string;
|
2021-12-18 00:00:07 +00:00
|
|
|
port?: number;
|
2021-12-18 00:13:02 +00:00
|
|
|
useSsl?: boolean;
|
2019-10-15 12:16:28 +00:00
|
|
|
accessKey: string;
|
|
|
|
accessSecret: string;
|
2019-07-07 08:48:24 +00:00
|
|
|
}
|
2018-09-14 16:07:20 +00:00
|
|
|
|
|
|
|
export class SmartBucket {
|
2019-10-14 18:55:07 +00:00
|
|
|
public config: ISmartBucketConfig;
|
|
|
|
|
2019-10-15 12:16:28 +00:00
|
|
|
public minioClient: plugins.minio.Client;
|
2019-10-14 21:53:41 +00:00
|
|
|
|
2018-09-14 16:07:20 +00:00
|
|
|
/**
|
|
|
|
* the constructor of SmartBucket
|
|
|
|
*/
|
|
|
|
constructor(configArg: ISmartBucketConfig) {
|
|
|
|
this.config = configArg;
|
2019-10-15 12:16:28 +00:00
|
|
|
this.minioClient = new plugins.minio.Client({
|
|
|
|
endPoint: this.config.endpoint,
|
2021-12-18 00:00:07 +00:00
|
|
|
port: configArg.port || 443,
|
2021-12-18 00:13:02 +00:00
|
|
|
useSSL: configArg.useSsl || true,
|
2019-10-15 12:16:28 +00:00
|
|
|
accessKey: this.config.accessKey,
|
2020-10-12 00:37:50 +00:00
|
|
|
secretKey: this.config.accessSecret,
|
2019-10-15 12:16:28 +00:00
|
|
|
});
|
2018-09-14 16:07:20 +00:00
|
|
|
}
|
|
|
|
|
2019-10-15 17:23:06 +00:00
|
|
|
public async createBucket(bucketNameArg: string) {
|
|
|
|
const bucket = await Bucket.createBucketByName(this, bucketNameArg);
|
|
|
|
return bucket;
|
2019-10-15 12:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public async removeBucket(bucketName: string) {
|
2019-10-15 17:23:06 +00:00
|
|
|
await Bucket.removeBucketByName(this, bucketName);
|
2019-10-15 12:16:28 +00:00
|
|
|
}
|
2019-10-14 21:53:41 +00:00
|
|
|
|
2019-10-15 17:23:06 +00:00
|
|
|
public async getBucketByName(bucketName: string) {
|
|
|
|
return Bucket.getBucketByName(this, bucketName);
|
2019-10-14 21:53:41 +00:00
|
|
|
}
|
2018-09-14 16:07:20 +00:00
|
|
|
}
|