tiny-oss 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +459 -52
- package/UPGRADING.md +151 -0
- package/dist/aws.d.ts +208 -0
- package/dist/azure.d.ts +204 -0
- package/dist/cos.d.ts +208 -0
- package/dist/index.d.ts +209 -0
- package/dist/obs.d.ts +208 -0
- package/dist/protocol.d.ts +271 -0
- package/dist/tiny-oss.aws.es.js +1052 -0
- package/dist/tiny-oss.aws.es.js.map +1 -0
- package/dist/tiny-oss.azure.es.js +882 -0
- package/dist/tiny-oss.azure.es.js.map +1 -0
- package/dist/tiny-oss.cos.es.js +984 -0
- package/dist/tiny-oss.cos.es.js.map +1 -0
- package/dist/tiny-oss.es.js +965 -0
- package/dist/tiny-oss.es.js.map +1 -0
- package/dist/tiny-oss.obs.es.js +1048 -0
- package/dist/tiny-oss.obs.es.js.map +1 -0
- package/dist/tiny-oss.protocol.es.js +588 -0
- package/dist/tiny-oss.protocol.es.js.map +1 -0
- package/package.json +78 -64
- package/dist/tiny-oss.js +0 -1642
- package/dist/tiny-oss.js.map +0 -1
- package/dist/tiny-oss.min.js +0 -35
- package/dist/tiny-oss.min.js.map +0 -1
- package/es/TinyOSS.js +0 -209
- package/es/index.js +0 -1
- package/es/utils/ajax.js +0 -61
- package/es/utils/index.js +0 -188
- package/lib/TinyOSS.js +0 -218
- package/lib/index.js +0 -3
- package/lib/utils/ajax.js +0 -66
- package/lib/utils/index.js +0 -203
- package/types/index.d.ts +0 -89
- package/vendor/digest.js +0 -390
package/dist/cos.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export declare const abortMultipartUpload: (options: Options, objectName: string, uploadId: string, multipartOptions?: MultipartOptions) => Promise<void>;
|
|
4
|
+
export declare const completeMultipartUpload: (options: Options, objectName: string, uploadId: string, parts: PartInfo[], multipartOptions?: MultipartOptions) => Promise<CompleteMultipartUploadResult>;
|
|
5
|
+
export declare const initMultipartUpload: (options: Options, objectName: string, multipartOptions?: MultipartOptions) => Promise<InitMultipartUploadResult>;
|
|
6
|
+
export declare const listParts: (options: Options, objectName: string, uploadId: string, query?: ListQuery, multipartOptions?: MultipartOptions) => Promise<ListPartsResult>;
|
|
7
|
+
export declare const listUploads: (options: Options, query?: ListUploadsQuery, multipartOptions?: MultipartOptions) => Promise<ListUploadsResult>;
|
|
8
|
+
export declare const multipartUpload: (options: Options, objectName: string, file: BlobLike | string, multipartOptions?: MultipartUploadOptions) => Promise<CompleteMultipartUploadResult>;
|
|
9
|
+
export declare const put: (options: Options, objectName: string, data: BlobLike | string, putOptions?: PutOptions) => Promise<any>;
|
|
10
|
+
export declare const signatureUrl: (options: Options, objectName: string, urlOptions?: SignatureUrlOptions) => string;
|
|
11
|
+
export declare const uploadPart: (options: Options, objectName: string, uploadId: string, partNo: number, data: BlobLike | string, start: number, end: number, multipartOptions?: MultipartOptions) => Promise<UploadPartResult>;
|
|
12
|
+
export declare const uploadPartCopy: (options: Options, objectName: string, uploadId: string, partNo: number, range: string, sourceData: SourceData, copyOptions?: UploadPartCopyOptions) => Promise<UploadPartCopyResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Bind client options to an operation function, so callers don't have to
|
|
15
|
+
* repeat the credentials on every call. The returned function keeps the
|
|
16
|
+
* operation's original signature minus the leading options argument.
|
|
17
|
+
*
|
|
18
|
+
* Unlike a client object factory, this never references operations it
|
|
19
|
+
* isn't given, so tree shaking keeps working: importing `put` plus
|
|
20
|
+
* `bindOptions` still excludes the multipart code from the bundle.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { put, bindOptions } from 'tiny-oss';
|
|
24
|
+
* const upload = bindOptions(put, { accessKeyId, accessKeySecret, region, bucket });
|
|
25
|
+
* upload('hello.txt', blob);
|
|
26
|
+
*/
|
|
27
|
+
export declare function bindOptions<O, A extends unknown[], R>(operation: (options: O, ...args: A) => R, options: O): (...args: A) => R;
|
|
28
|
+
/**
|
|
29
|
+
* fetch-based transport for Service Workers and Node.js, where
|
|
30
|
+
* XMLHttpRequest is unavailable. fetch cannot report intermediate
|
|
31
|
+
* upload progress, so a synthetic 0% event fires before sending and a
|
|
32
|
+
* 100% event after, with lengthComputable false.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fetchTransport(url: string, options: TransportOptions): Promise<TransportResponse>;
|
|
35
|
+
export declare function getTransport(): Transport;
|
|
36
|
+
/**
|
|
37
|
+
* Replace the network layer. Defaults to XMLHttpRequest; pass a
|
|
38
|
+
* fetch-based adapter in Service Workers or a wx.request-based adapter
|
|
39
|
+
* in WeChat mini programs.
|
|
40
|
+
*/
|
|
41
|
+
export declare function setTransport(transport: Transport): void;
|
|
42
|
+
/**
|
|
43
|
+
* wx.request-based transport for WeChat mini programs. Mini programs
|
|
44
|
+
* have no XMLHttpRequest and no Blob, so uploads must pass ArrayBuffer
|
|
45
|
+
* (see README). wx.request cannot report intermediate upload progress,
|
|
46
|
+
* so a synthetic 0% event fires before sending and a 100% event after,
|
|
47
|
+
* with lengthComputable false.
|
|
48
|
+
*/
|
|
49
|
+
export declare function wxRequestTransport(url: string, options: TransportOptions): Promise<TransportResponse>;
|
|
50
|
+
export interface Checkpoint {
|
|
51
|
+
file: BlobLike | string;
|
|
52
|
+
name: string;
|
|
53
|
+
uploadId: string;
|
|
54
|
+
partSize: number;
|
|
55
|
+
parts: PartInfo[];
|
|
56
|
+
doneParts: PartInfo[];
|
|
57
|
+
}
|
|
58
|
+
export interface CompleteMultipartUploadResult {
|
|
59
|
+
name: string;
|
|
60
|
+
etag: string;
|
|
61
|
+
bucket?: string;
|
|
62
|
+
res?: any;
|
|
63
|
+
}
|
|
64
|
+
export interface InitMultipartUploadResult {
|
|
65
|
+
name: string;
|
|
66
|
+
uploadId: string;
|
|
67
|
+
res?: any;
|
|
68
|
+
}
|
|
69
|
+
export interface ListPartsResult {
|
|
70
|
+
isTruncated: boolean;
|
|
71
|
+
nextPartNumberMarker: number;
|
|
72
|
+
parts: Part[];
|
|
73
|
+
res?: any;
|
|
74
|
+
}
|
|
75
|
+
export interface ListQuery {
|
|
76
|
+
"max-parts"?: number;
|
|
77
|
+
"part-number-marker"?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface ListUploadsQuery {
|
|
80
|
+
prefix?: string;
|
|
81
|
+
marker?: string;
|
|
82
|
+
"max-uploads"?: number;
|
|
83
|
+
"upload-id-marker"?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ListUploadsResult {
|
|
86
|
+
uploads: UploadInfo[];
|
|
87
|
+
isTruncated: boolean;
|
|
88
|
+
nextKeyMarker?: string;
|
|
89
|
+
nextUploadIdMarker?: string;
|
|
90
|
+
res?: any;
|
|
91
|
+
}
|
|
92
|
+
export interface MultipartOptions {
|
|
93
|
+
timeout?: number;
|
|
94
|
+
headers?: Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
export interface MultipartUploadOptions extends MultipartOptions {
|
|
97
|
+
parallel?: number;
|
|
98
|
+
partSize?: number;
|
|
99
|
+
checkpoint?: Checkpoint;
|
|
100
|
+
progress?: (percentage: number, checkpoint: Checkpoint, res?: any) => void;
|
|
101
|
+
meta?: Record<string, any>;
|
|
102
|
+
mime?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface ObjectCallback {
|
|
105
|
+
url: string;
|
|
106
|
+
host?: string;
|
|
107
|
+
body: string;
|
|
108
|
+
contentType?: string;
|
|
109
|
+
customValue?: object;
|
|
110
|
+
headers?: object;
|
|
111
|
+
}
|
|
112
|
+
export interface Options {
|
|
113
|
+
accessKeyId: string;
|
|
114
|
+
accessKeySecret: string;
|
|
115
|
+
stsToken?: string;
|
|
116
|
+
bucket?: string;
|
|
117
|
+
endpoint?: string;
|
|
118
|
+
region?: string;
|
|
119
|
+
internal?: boolean;
|
|
120
|
+
secure?: boolean;
|
|
121
|
+
timeout?: string | number;
|
|
122
|
+
cname?: boolean;
|
|
123
|
+
pathStyle?: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface Part {
|
|
126
|
+
PartNumber: number;
|
|
127
|
+
LastModified: string;
|
|
128
|
+
ETag: string;
|
|
129
|
+
Size: number;
|
|
130
|
+
}
|
|
131
|
+
export interface PartInfo {
|
|
132
|
+
number: number;
|
|
133
|
+
etag: string;
|
|
134
|
+
}
|
|
135
|
+
export interface Progress {
|
|
136
|
+
loaded: number;
|
|
137
|
+
total: number;
|
|
138
|
+
lengthComputable: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface PutOptions {
|
|
141
|
+
onprogress?: (e: Progress) => any;
|
|
142
|
+
}
|
|
143
|
+
export interface ResponseHeaderType {
|
|
144
|
+
"content-type"?: string;
|
|
145
|
+
"content-disposition"?: string;
|
|
146
|
+
"cache-control"?: string;
|
|
147
|
+
"content-encoding"?: string;
|
|
148
|
+
"content-language"?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface SignatureUrlOptions {
|
|
151
|
+
expires?: number;
|
|
152
|
+
method?: HTTPMethods;
|
|
153
|
+
"Content-Type"?: string;
|
|
154
|
+
process?: string;
|
|
155
|
+
response?: ResponseHeaderType;
|
|
156
|
+
callback?: ObjectCallback;
|
|
157
|
+
[key: string]: any;
|
|
158
|
+
}
|
|
159
|
+
export interface SourceData {
|
|
160
|
+
sourceKey: string;
|
|
161
|
+
sourceBucket?: string;
|
|
162
|
+
}
|
|
163
|
+
export interface TransportOptions {
|
|
164
|
+
method: string;
|
|
165
|
+
headers: Record<string, string>;
|
|
166
|
+
data?: any;
|
|
167
|
+
timeout?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Total payload size in bytes; transports without native progress
|
|
170
|
+
* events use it to fire 0%/100% synthetic events.
|
|
171
|
+
*/
|
|
172
|
+
total?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Upload progress. lengthComputable is false when the environment
|
|
175
|
+
* cannot report intermediate progress (fetch, wx.request); such
|
|
176
|
+
* adapters fire a 0% event before sending and a 100% event after.
|
|
177
|
+
*/
|
|
178
|
+
onprogress?: (e: Progress) => void;
|
|
179
|
+
}
|
|
180
|
+
export interface TransportResponse {
|
|
181
|
+
data: string;
|
|
182
|
+
headers: Record<string, string>;
|
|
183
|
+
status: number;
|
|
184
|
+
statusText: string;
|
|
185
|
+
}
|
|
186
|
+
export interface UploadInfo {
|
|
187
|
+
uploadId: string;
|
|
188
|
+
name: string;
|
|
189
|
+
initiated: string;
|
|
190
|
+
}
|
|
191
|
+
export interface UploadPartCopyOptions extends MultipartOptions {
|
|
192
|
+
headers?: Record<string, any>;
|
|
193
|
+
}
|
|
194
|
+
export interface UploadPartCopyResult {
|
|
195
|
+
etag: string;
|
|
196
|
+
lastModified: string;
|
|
197
|
+
res?: any;
|
|
198
|
+
}
|
|
199
|
+
export interface UploadPartResult {
|
|
200
|
+
name: string;
|
|
201
|
+
etag: string;
|
|
202
|
+
res?: any;
|
|
203
|
+
}
|
|
204
|
+
export type BlobLike = Blob | ArrayBuffer | Uint8Array;
|
|
205
|
+
export type HTTPMethods = "GET" | "POST" | "DELETE" | "PUT";
|
|
206
|
+
export type Transport = (url: string, options: TransportOptions) => Promise<TransportResponse>;
|
|
207
|
+
|
|
208
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export declare const abortMultipartUpload: (options: Options, objectName: string, uploadId: string, multipartOptions?: MultipartOptions) => Promise<void>;
|
|
4
|
+
export declare const completeMultipartUpload: (options: Options, objectName: string, uploadId: string, parts: PartInfo[], multipartOptions?: MultipartOptions) => Promise<CompleteMultipartUploadResult>;
|
|
5
|
+
export declare const initMultipartUpload: (options: Options, objectName: string, multipartOptions?: MultipartOptions) => Promise<InitMultipartUploadResult>;
|
|
6
|
+
export declare const listParts: (options: Options, objectName: string, uploadId: string, query?: ListQuery, multipartOptions?: MultipartOptions) => Promise<ListPartsResult>;
|
|
7
|
+
export declare const listUploads: (options: Options, query?: ListUploadsQuery, multipartOptions?: MultipartOptions) => Promise<ListUploadsResult>;
|
|
8
|
+
export declare const multipartUpload: (options: Options, objectName: string, file: BlobLike | string, multipartOptions?: MultipartUploadOptions) => Promise<CompleteMultipartUploadResult>;
|
|
9
|
+
export declare const put: (options: Options, objectName: string, data: BlobLike | string, putOptions?: PutOptions) => Promise<any>;
|
|
10
|
+
export declare const putSymlink: (options: Options, objectName: string, targetObjectName: string) => Promise<any>;
|
|
11
|
+
export declare const signatureUrl: (options: Options, objectName: string, urlOptions?: SignatureUrlOptions) => string;
|
|
12
|
+
export declare const uploadPart: (options: Options, objectName: string, uploadId: string, partNo: number, data: BlobLike | string, start: number, end: number, multipartOptions?: MultipartOptions) => Promise<UploadPartResult>;
|
|
13
|
+
export declare const uploadPartCopy: (options: Options, objectName: string, uploadId: string, partNo: number, range: string, sourceData: SourceData, copyOptions?: UploadPartCopyOptions) => Promise<UploadPartCopyResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Bind client options to an operation function, so callers don't have to
|
|
16
|
+
* repeat the credentials on every call. The returned function keeps the
|
|
17
|
+
* operation's original signature minus the leading options argument.
|
|
18
|
+
*
|
|
19
|
+
* Unlike a client object factory, this never references operations it
|
|
20
|
+
* isn't given, so tree shaking keeps working: importing `put` plus
|
|
21
|
+
* `bindOptions` still excludes the multipart code from the bundle.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { put, bindOptions } from 'tiny-oss';
|
|
25
|
+
* const upload = bindOptions(put, { accessKeyId, accessKeySecret, region, bucket });
|
|
26
|
+
* upload('hello.txt', blob);
|
|
27
|
+
*/
|
|
28
|
+
export declare function bindOptions<O, A extends unknown[], R>(operation: (options: O, ...args: A) => R, options: O): (...args: A) => R;
|
|
29
|
+
/**
|
|
30
|
+
* fetch-based transport for Service Workers and Node.js, where
|
|
31
|
+
* XMLHttpRequest is unavailable. fetch cannot report intermediate
|
|
32
|
+
* upload progress, so a synthetic 0% event fires before sending and a
|
|
33
|
+
* 100% event after, with lengthComputable false.
|
|
34
|
+
*/
|
|
35
|
+
export declare function fetchTransport(url: string, options: TransportOptions): Promise<TransportResponse>;
|
|
36
|
+
export declare function getTransport(): Transport;
|
|
37
|
+
/**
|
|
38
|
+
* Replace the network layer. Defaults to XMLHttpRequest; pass a
|
|
39
|
+
* fetch-based adapter in Service Workers or a wx.request-based adapter
|
|
40
|
+
* in WeChat mini programs.
|
|
41
|
+
*/
|
|
42
|
+
export declare function setTransport(transport: Transport): void;
|
|
43
|
+
/**
|
|
44
|
+
* wx.request-based transport for WeChat mini programs. Mini programs
|
|
45
|
+
* have no XMLHttpRequest and no Blob, so uploads must pass ArrayBuffer
|
|
46
|
+
* (see README). wx.request cannot report intermediate upload progress,
|
|
47
|
+
* so a synthetic 0% event fires before sending and a 100% event after,
|
|
48
|
+
* with lengthComputable false.
|
|
49
|
+
*/
|
|
50
|
+
export declare function wxRequestTransport(url: string, options: TransportOptions): Promise<TransportResponse>;
|
|
51
|
+
export interface Checkpoint {
|
|
52
|
+
file: BlobLike | string;
|
|
53
|
+
name: string;
|
|
54
|
+
uploadId: string;
|
|
55
|
+
partSize: number;
|
|
56
|
+
parts: PartInfo[];
|
|
57
|
+
doneParts: PartInfo[];
|
|
58
|
+
}
|
|
59
|
+
export interface CompleteMultipartUploadResult {
|
|
60
|
+
name: string;
|
|
61
|
+
etag: string;
|
|
62
|
+
bucket?: string;
|
|
63
|
+
res?: any;
|
|
64
|
+
}
|
|
65
|
+
export interface InitMultipartUploadResult {
|
|
66
|
+
name: string;
|
|
67
|
+
uploadId: string;
|
|
68
|
+
res?: any;
|
|
69
|
+
}
|
|
70
|
+
export interface ListPartsResult {
|
|
71
|
+
isTruncated: boolean;
|
|
72
|
+
nextPartNumberMarker: number;
|
|
73
|
+
parts: Part[];
|
|
74
|
+
res?: any;
|
|
75
|
+
}
|
|
76
|
+
export interface ListQuery {
|
|
77
|
+
"max-parts"?: number;
|
|
78
|
+
"part-number-marker"?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface ListUploadsQuery {
|
|
81
|
+
prefix?: string;
|
|
82
|
+
marker?: string;
|
|
83
|
+
"max-uploads"?: number;
|
|
84
|
+
"upload-id-marker"?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ListUploadsResult {
|
|
87
|
+
uploads: UploadInfo[];
|
|
88
|
+
isTruncated: boolean;
|
|
89
|
+
nextKeyMarker?: string;
|
|
90
|
+
nextUploadIdMarker?: string;
|
|
91
|
+
res?: any;
|
|
92
|
+
}
|
|
93
|
+
export interface MultipartOptions {
|
|
94
|
+
timeout?: number;
|
|
95
|
+
headers?: Record<string, any>;
|
|
96
|
+
}
|
|
97
|
+
export interface MultipartUploadOptions extends MultipartOptions {
|
|
98
|
+
parallel?: number;
|
|
99
|
+
partSize?: number;
|
|
100
|
+
checkpoint?: Checkpoint;
|
|
101
|
+
progress?: (percentage: number, checkpoint: Checkpoint, res?: any) => void;
|
|
102
|
+
meta?: Record<string, any>;
|
|
103
|
+
mime?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface ObjectCallback {
|
|
106
|
+
url: string;
|
|
107
|
+
host?: string;
|
|
108
|
+
body: string;
|
|
109
|
+
contentType?: string;
|
|
110
|
+
customValue?: object;
|
|
111
|
+
headers?: object;
|
|
112
|
+
}
|
|
113
|
+
export interface Options {
|
|
114
|
+
accessKeyId: string;
|
|
115
|
+
accessKeySecret: string;
|
|
116
|
+
stsToken?: string;
|
|
117
|
+
bucket?: string;
|
|
118
|
+
endpoint?: string;
|
|
119
|
+
region?: string;
|
|
120
|
+
internal?: boolean;
|
|
121
|
+
secure?: boolean;
|
|
122
|
+
timeout?: string | number;
|
|
123
|
+
cname?: boolean;
|
|
124
|
+
pathStyle?: boolean;
|
|
125
|
+
}
|
|
126
|
+
export interface Part {
|
|
127
|
+
PartNumber: number;
|
|
128
|
+
LastModified: string;
|
|
129
|
+
ETag: string;
|
|
130
|
+
Size: number;
|
|
131
|
+
}
|
|
132
|
+
export interface PartInfo {
|
|
133
|
+
number: number;
|
|
134
|
+
etag: string;
|
|
135
|
+
}
|
|
136
|
+
export interface Progress {
|
|
137
|
+
loaded: number;
|
|
138
|
+
total: number;
|
|
139
|
+
lengthComputable: boolean;
|
|
140
|
+
}
|
|
141
|
+
export interface PutOptions {
|
|
142
|
+
onprogress?: (e: Progress) => any;
|
|
143
|
+
}
|
|
144
|
+
export interface ResponseHeaderType {
|
|
145
|
+
"content-type"?: string;
|
|
146
|
+
"content-disposition"?: string;
|
|
147
|
+
"cache-control"?: string;
|
|
148
|
+
"content-encoding"?: string;
|
|
149
|
+
"content-language"?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface SignatureUrlOptions {
|
|
152
|
+
expires?: number;
|
|
153
|
+
method?: HTTPMethods;
|
|
154
|
+
"Content-Type"?: string;
|
|
155
|
+
process?: string;
|
|
156
|
+
response?: ResponseHeaderType;
|
|
157
|
+
callback?: ObjectCallback;
|
|
158
|
+
[key: string]: any;
|
|
159
|
+
}
|
|
160
|
+
export interface SourceData {
|
|
161
|
+
sourceKey: string;
|
|
162
|
+
sourceBucket?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface TransportOptions {
|
|
165
|
+
method: string;
|
|
166
|
+
headers: Record<string, string>;
|
|
167
|
+
data?: any;
|
|
168
|
+
timeout?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Total payload size in bytes; transports without native progress
|
|
171
|
+
* events use it to fire 0%/100% synthetic events.
|
|
172
|
+
*/
|
|
173
|
+
total?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Upload progress. lengthComputable is false when the environment
|
|
176
|
+
* cannot report intermediate progress (fetch, wx.request); such
|
|
177
|
+
* adapters fire a 0% event before sending and a 100% event after.
|
|
178
|
+
*/
|
|
179
|
+
onprogress?: (e: Progress) => void;
|
|
180
|
+
}
|
|
181
|
+
export interface TransportResponse {
|
|
182
|
+
data: string;
|
|
183
|
+
headers: Record<string, string>;
|
|
184
|
+
status: number;
|
|
185
|
+
statusText: string;
|
|
186
|
+
}
|
|
187
|
+
export interface UploadInfo {
|
|
188
|
+
uploadId: string;
|
|
189
|
+
name: string;
|
|
190
|
+
initiated: string;
|
|
191
|
+
}
|
|
192
|
+
export interface UploadPartCopyOptions extends MultipartOptions {
|
|
193
|
+
headers?: Record<string, any>;
|
|
194
|
+
}
|
|
195
|
+
export interface UploadPartCopyResult {
|
|
196
|
+
etag: string;
|
|
197
|
+
lastModified: string;
|
|
198
|
+
res?: any;
|
|
199
|
+
}
|
|
200
|
+
export interface UploadPartResult {
|
|
201
|
+
name: string;
|
|
202
|
+
etag: string;
|
|
203
|
+
res?: any;
|
|
204
|
+
}
|
|
205
|
+
export type BlobLike = Blob | ArrayBuffer | Uint8Array;
|
|
206
|
+
export type HTTPMethods = "GET" | "POST" | "DELETE" | "PUT";
|
|
207
|
+
export type Transport = (url: string, options: TransportOptions) => Promise<TransportResponse>;
|
|
208
|
+
|
|
209
|
+
export {};
|
package/dist/obs.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export declare const abortMultipartUpload: (options: Options, objectName: string, uploadId: string, multipartOptions?: MultipartOptions) => Promise<void>;
|
|
4
|
+
export declare const completeMultipartUpload: (options: Options, objectName: string, uploadId: string, parts: PartInfo[], multipartOptions?: MultipartOptions) => Promise<CompleteMultipartUploadResult>;
|
|
5
|
+
export declare const initMultipartUpload: (options: Options, objectName: string, multipartOptions?: MultipartOptions) => Promise<InitMultipartUploadResult>;
|
|
6
|
+
export declare const listParts: (options: Options, objectName: string, uploadId: string, query?: ListQuery, multipartOptions?: MultipartOptions) => Promise<ListPartsResult>;
|
|
7
|
+
export declare const listUploads: (options: Options, query?: ListUploadsQuery, multipartOptions?: MultipartOptions) => Promise<ListUploadsResult>;
|
|
8
|
+
export declare const multipartUpload: (options: Options, objectName: string, file: BlobLike | string, multipartOptions?: MultipartUploadOptions) => Promise<CompleteMultipartUploadResult>;
|
|
9
|
+
export declare const put: (options: Options, objectName: string, data: BlobLike | string, putOptions?: PutOptions) => Promise<any>;
|
|
10
|
+
export declare const signatureUrl: (options: Options, objectName: string, urlOptions?: SignatureUrlOptions) => string;
|
|
11
|
+
export declare const uploadPart: (options: Options, objectName: string, uploadId: string, partNo: number, data: BlobLike | string, start: number, end: number, multipartOptions?: MultipartOptions) => Promise<UploadPartResult>;
|
|
12
|
+
export declare const uploadPartCopy: (options: Options, objectName: string, uploadId: string, partNo: number, range: string, sourceData: SourceData, copyOptions?: UploadPartCopyOptions) => Promise<UploadPartCopyResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Bind client options to an operation function, so callers don't have to
|
|
15
|
+
* repeat the credentials on every call. The returned function keeps the
|
|
16
|
+
* operation's original signature minus the leading options argument.
|
|
17
|
+
*
|
|
18
|
+
* Unlike a client object factory, this never references operations it
|
|
19
|
+
* isn't given, so tree shaking keeps working: importing `put` plus
|
|
20
|
+
* `bindOptions` still excludes the multipart code from the bundle.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { put, bindOptions } from 'tiny-oss';
|
|
24
|
+
* const upload = bindOptions(put, { accessKeyId, accessKeySecret, region, bucket });
|
|
25
|
+
* upload('hello.txt', blob);
|
|
26
|
+
*/
|
|
27
|
+
export declare function bindOptions<O, A extends unknown[], R>(operation: (options: O, ...args: A) => R, options: O): (...args: A) => R;
|
|
28
|
+
/**
|
|
29
|
+
* fetch-based transport for Service Workers and Node.js, where
|
|
30
|
+
* XMLHttpRequest is unavailable. fetch cannot report intermediate
|
|
31
|
+
* upload progress, so a synthetic 0% event fires before sending and a
|
|
32
|
+
* 100% event after, with lengthComputable false.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fetchTransport(url: string, options: TransportOptions): Promise<TransportResponse>;
|
|
35
|
+
export declare function getTransport(): Transport;
|
|
36
|
+
/**
|
|
37
|
+
* Replace the network layer. Defaults to XMLHttpRequest; pass a
|
|
38
|
+
* fetch-based adapter in Service Workers or a wx.request-based adapter
|
|
39
|
+
* in WeChat mini programs.
|
|
40
|
+
*/
|
|
41
|
+
export declare function setTransport(transport: Transport): void;
|
|
42
|
+
/**
|
|
43
|
+
* wx.request-based transport for WeChat mini programs. Mini programs
|
|
44
|
+
* have no XMLHttpRequest and no Blob, so uploads must pass ArrayBuffer
|
|
45
|
+
* (see README). wx.request cannot report intermediate upload progress,
|
|
46
|
+
* so a synthetic 0% event fires before sending and a 100% event after,
|
|
47
|
+
* with lengthComputable false.
|
|
48
|
+
*/
|
|
49
|
+
export declare function wxRequestTransport(url: string, options: TransportOptions): Promise<TransportResponse>;
|
|
50
|
+
export interface Checkpoint {
|
|
51
|
+
file: BlobLike | string;
|
|
52
|
+
name: string;
|
|
53
|
+
uploadId: string;
|
|
54
|
+
partSize: number;
|
|
55
|
+
parts: PartInfo[];
|
|
56
|
+
doneParts: PartInfo[];
|
|
57
|
+
}
|
|
58
|
+
export interface CompleteMultipartUploadResult {
|
|
59
|
+
name: string;
|
|
60
|
+
etag: string;
|
|
61
|
+
bucket?: string;
|
|
62
|
+
res?: any;
|
|
63
|
+
}
|
|
64
|
+
export interface InitMultipartUploadResult {
|
|
65
|
+
name: string;
|
|
66
|
+
uploadId: string;
|
|
67
|
+
res?: any;
|
|
68
|
+
}
|
|
69
|
+
export interface ListPartsResult {
|
|
70
|
+
isTruncated: boolean;
|
|
71
|
+
nextPartNumberMarker: number;
|
|
72
|
+
parts: Part[];
|
|
73
|
+
res?: any;
|
|
74
|
+
}
|
|
75
|
+
export interface ListQuery {
|
|
76
|
+
"max-parts"?: number;
|
|
77
|
+
"part-number-marker"?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface ListUploadsQuery {
|
|
80
|
+
prefix?: string;
|
|
81
|
+
marker?: string;
|
|
82
|
+
"max-uploads"?: number;
|
|
83
|
+
"upload-id-marker"?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ListUploadsResult {
|
|
86
|
+
uploads: UploadInfo[];
|
|
87
|
+
isTruncated: boolean;
|
|
88
|
+
nextKeyMarker?: string;
|
|
89
|
+
nextUploadIdMarker?: string;
|
|
90
|
+
res?: any;
|
|
91
|
+
}
|
|
92
|
+
export interface MultipartOptions {
|
|
93
|
+
timeout?: number;
|
|
94
|
+
headers?: Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
export interface MultipartUploadOptions extends MultipartOptions {
|
|
97
|
+
parallel?: number;
|
|
98
|
+
partSize?: number;
|
|
99
|
+
checkpoint?: Checkpoint;
|
|
100
|
+
progress?: (percentage: number, checkpoint: Checkpoint, res?: any) => void;
|
|
101
|
+
meta?: Record<string, any>;
|
|
102
|
+
mime?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface ObjectCallback {
|
|
105
|
+
url: string;
|
|
106
|
+
host?: string;
|
|
107
|
+
body: string;
|
|
108
|
+
contentType?: string;
|
|
109
|
+
customValue?: object;
|
|
110
|
+
headers?: object;
|
|
111
|
+
}
|
|
112
|
+
export interface Options {
|
|
113
|
+
accessKeyId: string;
|
|
114
|
+
accessKeySecret: string;
|
|
115
|
+
stsToken?: string;
|
|
116
|
+
bucket?: string;
|
|
117
|
+
endpoint?: string;
|
|
118
|
+
region?: string;
|
|
119
|
+
internal?: boolean;
|
|
120
|
+
secure?: boolean;
|
|
121
|
+
timeout?: string | number;
|
|
122
|
+
cname?: boolean;
|
|
123
|
+
pathStyle?: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface Part {
|
|
126
|
+
PartNumber: number;
|
|
127
|
+
LastModified: string;
|
|
128
|
+
ETag: string;
|
|
129
|
+
Size: number;
|
|
130
|
+
}
|
|
131
|
+
export interface PartInfo {
|
|
132
|
+
number: number;
|
|
133
|
+
etag: string;
|
|
134
|
+
}
|
|
135
|
+
export interface Progress {
|
|
136
|
+
loaded: number;
|
|
137
|
+
total: number;
|
|
138
|
+
lengthComputable: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface PutOptions {
|
|
141
|
+
onprogress?: (e: Progress) => any;
|
|
142
|
+
}
|
|
143
|
+
export interface ResponseHeaderType {
|
|
144
|
+
"content-type"?: string;
|
|
145
|
+
"content-disposition"?: string;
|
|
146
|
+
"cache-control"?: string;
|
|
147
|
+
"content-encoding"?: string;
|
|
148
|
+
"content-language"?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface SignatureUrlOptions {
|
|
151
|
+
expires?: number;
|
|
152
|
+
method?: HTTPMethods;
|
|
153
|
+
"Content-Type"?: string;
|
|
154
|
+
process?: string;
|
|
155
|
+
response?: ResponseHeaderType;
|
|
156
|
+
callback?: ObjectCallback;
|
|
157
|
+
[key: string]: any;
|
|
158
|
+
}
|
|
159
|
+
export interface SourceData {
|
|
160
|
+
sourceKey: string;
|
|
161
|
+
sourceBucket?: string;
|
|
162
|
+
}
|
|
163
|
+
export interface TransportOptions {
|
|
164
|
+
method: string;
|
|
165
|
+
headers: Record<string, string>;
|
|
166
|
+
data?: any;
|
|
167
|
+
timeout?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Total payload size in bytes; transports without native progress
|
|
170
|
+
* events use it to fire 0%/100% synthetic events.
|
|
171
|
+
*/
|
|
172
|
+
total?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Upload progress. lengthComputable is false when the environment
|
|
175
|
+
* cannot report intermediate progress (fetch, wx.request); such
|
|
176
|
+
* adapters fire a 0% event before sending and a 100% event after.
|
|
177
|
+
*/
|
|
178
|
+
onprogress?: (e: Progress) => void;
|
|
179
|
+
}
|
|
180
|
+
export interface TransportResponse {
|
|
181
|
+
data: string;
|
|
182
|
+
headers: Record<string, string>;
|
|
183
|
+
status: number;
|
|
184
|
+
statusText: string;
|
|
185
|
+
}
|
|
186
|
+
export interface UploadInfo {
|
|
187
|
+
uploadId: string;
|
|
188
|
+
name: string;
|
|
189
|
+
initiated: string;
|
|
190
|
+
}
|
|
191
|
+
export interface UploadPartCopyOptions extends MultipartOptions {
|
|
192
|
+
headers?: Record<string, any>;
|
|
193
|
+
}
|
|
194
|
+
export interface UploadPartCopyResult {
|
|
195
|
+
etag: string;
|
|
196
|
+
lastModified: string;
|
|
197
|
+
res?: any;
|
|
198
|
+
}
|
|
199
|
+
export interface UploadPartResult {
|
|
200
|
+
name: string;
|
|
201
|
+
etag: string;
|
|
202
|
+
res?: any;
|
|
203
|
+
}
|
|
204
|
+
export type BlobLike = Blob | ArrayBuffer | Uint8Array;
|
|
205
|
+
export type HTTPMethods = "GET" | "POST" | "DELETE" | "PUT";
|
|
206
|
+
export type Transport = (url: string, options: TransportOptions) => Promise<TransportResponse>;
|
|
207
|
+
|
|
208
|
+
export {};
|