mcos-sdk
v0.0.1
Published
A object stroage service sdk that supports ali-oss, qiniu storage, tencent-cos, upyun stoarge and minio
Downloads
17
Readme
MCOS-SDK
Introduction
A object stroage service sdk that supports ali-oss, qiniu storage, tencent-cos, upyun stoarge and minio.
Regions
| Region Id | Region Name | |:-----|:------| | Ali OSS | | oss-cn-beijing | beijing | | oss-cn-hangzhou | hangzhou | | oss-cn-shanghai | shanghai | | oss-cn-qingdao | qingdao | | oss-cn-shenzhen | shenzhen | | oss-cn-hongkong | hongkong | | oss-us-west-1 | us | | oss-ap-southeast-1 | singapore | | Qiniu Storage | | | z0 | huadong | | z1 | huabei | | z2 | huanan | | na0 | North US | | as0 | South East Asia | | Tencent COS | | ap-beijing | beijing | | ap-beijing-1 | huabei | | ap-shanghai | shanghai | | ap-guangzhou | guangzhou | | ap-chengdu | chengdu | | ap-chongqing | chongqing | | ap-singapore | singapore | | ap-hongkong | hongkong | | na-toronto | toronto | | eu-frankfurt | frankfurt | | ap-mumbai | mumbai | | ap-seoul | seoul | | na-siliconvalley | siliconvalley | | na-ashburn | ashburn | | ap-bangkok | bangkok | | eu-moscow | moscow |
Usage
Bucket
import {
Mac,
IBucketService,
OSSBucketService,
QiniuBucketService,
COSBucketService
} from 'mcos-sdk';
const accessKey = '';
const secretKey = '';
const mac: Mac = new Mac(accessKey, secretKey);
// Ali OSS
const bucketService: IBucketService = new OSSBucketService(mac);
// Qiniu Storage
const bucketService: IBucketService = new QiniuBucketService(mac);
// Tencent COS
const bucketService: IBucketService = new COSBucketService(mac);
BucketService API
listBuckets(): Promise<Bucket[]>;
Get all buckets.
putBucket(region: string, name: string, options?: IPutBucketOptions): Promise;
Create a new bucket.
| Param | Introduction | Required | |:----------|:-------------|:------| | region | The region of bucket | true | | options.acl | private / public-read / public-read-write, The qiniu storage is only supports private and public-read-write | false | | options.StorageClass | Standard / IA / Archive | false, only available for Ali OSS |
deleteBucket(name: string, region?: string): Promise;
Delete a bucket.
| Param | Introduction | Required | |:----------|:-------------|:------| | name | The bucket name | true | | region | The region of the bucket | Qiniu Storage is false, others are true |
setBucketACL(name: string, acl: string, region?: string): Promise;
Set a bucket ACL.
| Param | Introduction | Required | |:----------|:-------------|:------| | name | true | The bucket name | | acl | true |private / public-read / public-read-write, The qiniu storage is only supports private and public-read-write | | region | The region of the bucket | Qiniu Storage is false, others are true |
Object
import {
Mac,
IObjectService,
OSSObjectService,
QiniuObjectService,
COSObjectService
} from 'mcos-sdk';
const accessKey = '';
const secretKey = '';
const mac: Mac = new Mac(accessKey, secretKey);
// Ali OSS
const objectService: IObjectService = new OSSObjectService(mac);
// Qiniu Storage
const objectService: IObjectService = new QiniuObjectService(mac);
// Tencent COS
const objectService: IObjectService = new COSObjectService(mac);