0.0.1 • Published 5 years ago

mcos-sdk v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

MCOS-SDK

Introduction

A object stroage service sdk that supports ali-oss, qiniu storage, tencent-cos, upyun stoarge and minio.

Regions

Region IdRegion Name
Ali OSS
oss-cn-beijingbeijing
oss-cn-hangzhouhangzhou
oss-cn-shanghaishanghai
oss-cn-qingdaoqingdao
oss-cn-shenzhenshenzhen
oss-cn-hongkonghongkong
oss-us-west-1us
oss-ap-southeast-1singapore
Qiniu Storage
z0huadong
z1huabei
z2huanan
na0North US
as0South East Asia
Tencent COS
ap-beijingbeijing
ap-beijing-1huabei
ap-shanghaishanghai
ap-guangzhouguangzhou
ap-chengduchengdu
ap-chongqingchongqing
ap-singaporesingapore
ap-hongkonghongkong
na-torontotoronto
eu-frankfurtfrankfurt
ap-mumbaimumbai
ap-seoulseoul
na-siliconvalleysiliconvalley
na-ashburnashburn
ap-bangkokbangkok
eu-moscowmoscow

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.

ParamIntroductionRequired
regionThe region of buckettrue
options.aclprivate / public-read / public-read-write, The qiniu storage is only supports private and public-read-writefalse
options.StorageClassStandard / IA / Archivefalse, only available for Ali OSS
deleteBucket(name: string, region?: string): Promise;

Delete a bucket.

ParamIntroductionRequired
nameThe bucket nametrue
regionThe region of the bucketQiniu Storage is false, others are true
setBucketACL(name: string, acl: string, region?: string): Promise;

Set a bucket ACL.

ParamIntroductionRequired
nametrueThe bucket name
acltrueprivate / public-read / public-read-write, The qiniu storage is only supports private and public-read-write
regionThe region of the bucketQiniu 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);

ObjectService API

moveObject(bucket: string, source: string, target: string): Promise;
deleteObject(bucket: string, name: string, region?: string): Promise;
listObjects(bucket: string, query?: IListObjectsQuery, region?: string): Promise;