FIX: export OSS class

This commit is contained in:
ptrdu
2018-11-21 17:55:49 +08:00
parent 67d754b35d
commit 46d809eaa4
5 changed files with 599 additions and 625 deletions
-63
View File
@@ -1,63 +0,0 @@
import {
ACLType,
CopyAndPutMetaResult,
CopyObjectOptions,
DeleteMultiOptions,
DeleteMultiResult,
GetObjectOptions,
GetObjectResult,
GetStreamOptions,
GetStreamResult,
HeadObjectOptions,
HeadObjectResult,
ListObjectResult,
ListObjectsQuery,
NormalSuccessResponse,
PutObjectOptions,
PutObjectResult,
PutStreamOptions,
RequestOptions,
SignatureUrlOptions,
UserMeta
} from "./index";
export interface ClusterType {
host: string;
accessKeyId: string;
accessKeySecret: string;
}
export interface ClusterOptions {
clusters: ClusterType[];
schedule?: string;
}
export class Cluster {
constructor(options: ClusterOptions)
list(query: ListObjectsQuery | null, options: RequestOptions): Promise<ListObjectResult>;
put(name: string, file: any, options?: PutObjectOptions): Promise<PutObjectResult>;
putStream(name: string, stream: any, options?: PutStreamOptions): Promise<{ name: string, res: NormalSuccessResponse }>;
head(name: string, options?: HeadObjectOptions): Promise<HeadObjectResult>;
get(name: string, file?: any, options?: GetObjectOptions): Promise<GetObjectResult>;
getStream(name?: string, options?: GetStreamOptions): Promise<GetStreamResult>;
delete(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
copy(name: string, sourceName: string, options?: CopyObjectOptions): Promise<CopyAndPutMetaResult>;
putMeta(name: string, meta: UserMeta, options: RequestOptions): Promise<CopyAndPutMetaResult>;
deleteMulti(names: string[], options?: DeleteMultiOptions): Promise<DeleteMultiResult>;
signatureUrl(name: string, options?: SignatureUrlOptions): string;
putACL(name: string, acl: ACLType, options?: RequestOptions): Promise<NormalSuccessResponse>;
restore(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
}
-71
View File
@@ -1,71 +0,0 @@
import { NormalSuccessResponse, RequestOptions } from "./index";
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
bucket: string; // the default bucket you want to access If you don't have any bucket, please use putBucket() create one first.
region?: string; // the bucket data region location, please see Data Regions, default is oss-cn-hangzhou
internal?: boolean; // access OSS with aliyun internal network or not, default is false If your servers are running on aliyun too, you can set true to save lot of money.
timeout?: string | number; // instance level timeout for all operations, default is 60s
}
export interface ImageGetOptions {
timeout?: number;
headers?: object;
}
export interface StyleData {
Name: string; // style name
Content: string; // style content
CreateTime: string; // style create time
LastModifyTime: string; // style last modify time
}
export class ImageClient {
constructor(options: ImageClientOptions)
/**
* Get an image from the image channel.
*/
get(name: string, file?: any, options?: ImageGetOptions): Promise<{ content: any, res: NormalSuccessResponse }>;
/**
* Get an image read stream.
*/
getStream(name: string, options?: ImageGetOptions): Promise<{ stream: any, res: NormalSuccessResponse }>;
/**
* Get a image exif info by image object name from the image channel.
*/
getExif(name: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* Get a image info and exif info by image object name from the image channel.
*/
getInfo(name: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* todo
*/
putStyle(name: string, style: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* Get a style by name from the image channel.
*/
getStyle(name: string, options?: RequestOptions): Promise<{ data: StyleData, res: NormalSuccessResponse}>;
/**
* Get all styles from the image channel.
*/
listStyle(options?: RequestOptions): Promise<StyleData[]>;
/**
* todo
*/
deleteStyle(styleName: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
/**
* Create a signature url for directly download.
*/
signatureUrl(name: string, options?: { expires?: string, timeout?: string }): string;
}
+19 -27
View File
@@ -1,34 +1,26 @@
import OSS from "ali-oss";
import * as OSS from 'ali-oss';
const client = new OSS({
const ossOptions: OSS.Options = {
accessKeyId: 'your access key',
accessKeySecret: 'your access secret',
bucket: 'your bucket name',
region: 'oss-cn-hangzhou'
});
};
const ImageClient = OSS.ImageClient({
imageHost: 'host',
accessKeySecret: "secret",
accessKeyId: 'id',
bucket: "",
internal: false,
region: "",
timeout: 2000
});
const client = new OSS(ossOptions);
const clusterOptions: OSS.ClusterOptions = {
clusters: [],
};
const clusterClient = new OSS.Cluster(clusterOptions);
const imageOptions: OSS.ImageClientOptions = {
imageHost: 'xxxx',
accessKeyId: 'xxxx',
accessKeySecret: 'xxxx',
bucket: 'xxxx'
};
const imageClient = new OSS.ImageClient(imageOptions);
const cluster = OSS.Cluster({
clusters: [
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
],
schedule: 'masterSlave',
});
+576 -463
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -1,3 +1,6 @@
{
"extends": "dtslint/dt.json"
"extends": "dtslint/dt.json",
"rules": {
"no-mergeable-namespace": false
}
}