FEAT: add test

This commit is contained in:
ptrdu
2018-09-29 17:49:53 +08:00
parent 8c7758f7ef
commit c56edf64cc
3 changed files with 37 additions and 17 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
import {NormalSuccessResponse, RequestOptions} from "./index";
import { NormalSuccessResponse, RequestOptions } from "./index";
export interface Options {
export interface ImageClientOptions {
imageHost: string, // your image service domain that binding to a OSS bucket
accessKeyId: string, // access key you create on aliyun console website
accessKeySecret: string, // access secret you create
@@ -21,8 +21,8 @@ export interface StyleData {
CreateTime: string, // style create time
LastModifyTime: string // style last modify time
}
export class Client {
constructor(options: Options)
export class ImageClient {
constructor(options: ImageClientOptions)
/**
* Get an image from the image channel.
+22 -5
View File
@@ -5,14 +5,31 @@ const client = new OSS({
accessKeySecret: 'your access secret',
bucket: 'your bucket name',
region: 'oss-cn-hangzhou'
});
})
const ImageClient = OSS.ImageClient({
imageHost: 'xxxx',
accessKeySecret: "xxxx",
accessKeyId: 'xxxxxx',
imageHost: 'host',
accessKeySecret: "secret",
accessKeyId: 'id',
bucket: "",
internal: false,
region: "",
timeout: undefined
timeout: 2000
})
const cluster = OSS.Cluster({
clusters: [
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
],
schedule: 'masterSlave',
})
+11 -8
View File
@@ -8,6 +8,10 @@
import * as ImageClientDefinition from './ImageClient'
import * as ClusterDefinition from "./Cluster"
import {ImageClient} from "./ImageClient";
export * from './ImageClient'
export * from './Cluster'
export interface Options {
accessKeyId: string, // access secret you create
@@ -22,7 +26,10 @@ export interface Options {
}
export type Bucket = {
name: string,
region: string,
creationDate: string,
StorageClass: StorageType
}
export type StorageType = "Standard" | "IA" | "Archive"
@@ -430,13 +437,9 @@ export interface GetRtmpUrlOptions {
timeout?: number // the operation timeout
}
export interface ObjectInterface {
}
export default class OSS {
// the image client
public static ImageClient: (options: ImageClientDefinition.Options) => ImageClientDefinition.Client
public static ImageClient: (options: ImageClientDefinition.ImageClientOptions) => ImageClientDefinition.ImageClient
public static Cluster: (options: ClusterDefinition.ClusterOptions) => ClusterDefinition.Cluster
constructor(options: Options)
@@ -455,7 +458,8 @@ export default class OSS {
/**
* Create a new bucket.
* @param {string} name - bucket name If bucket exists and not belong to current account, will throw BucketAlreadyExistsError. If bucket not exists, will create a new bucket and set it's ACL.
* @param {string} name - bucket name If bucket exists and not belong to current account, will throw BucketAlreadyExistsError.
* If bucket not exists, will create a new bucket and set it's ACL.
* @param {PutBucketOptions} options - optional parameters
* @return { Promise<{ bucket: string, res: NormalSuccessResponse }> }
*/
@@ -952,4 +956,3 @@ export default class OSS {
getRtmpUrl(channelId?: string, options?: GetRtmpUrlOptions): string
}