UNPKG

40 kBTypeScriptView Raw
1// Type definitions for ali-oss 6.16
2// Project: https://github.com/aliyun/oss-nodejs-sdk
3// Definitions by: Ptrdu <https://github.com/ptrdu>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 3.3
6
7export = OSS;
8
9// basic OSS
10declare namespace OSS {
11 interface Options {
12 /** access secret you create */
13 accessKeyId: string;
14 /** access secret you create */
15 accessKeySecret: string;
16 /** used by temporary authorization */
17 stsToken?: string | undefined;
18 /** the default bucket you want to access If you don't have any bucket, please use putBucket() create one first. */
19 bucket?: string | undefined;
20 /** oss region domain. It takes priority over region. */
21 endpoint?: string | undefined;
22 /** the bucket data region location, please see Data Regions, default is oss-cn-hangzhou. */
23 region?: string | undefined;
24 /** 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. */
25 internal?: boolean | undefined;
26 /** instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol. */
27 secure?: boolean | undefined;
28 /** instance level timeout for all operations, default is 60s */
29 timeout?: string | number | undefined;
30 /** use custom domain name */
31 cname?: boolean | undefined;
32 /** use time (ms) of refresh STSToken interval it should be less than sts info expire interval, default is 300000ms(5min) when sts info expires. */
33 refreshSTSTokenInterval?: number;
34 /** used by auto set stsToken、accessKeyId、accessKeySecret when sts info expires. return value must be object contains stsToken、accessKeyId、accessKeySecret */
35 refreshSTSToken?: () => Promise<{ accessKeyId: string, accessKeySecret: string, stsToken: string }>;
36 }
37
38 /**
39 * Generate STS Authorization
40 */
41 class STS {
42 constructor(options: STSOptions);
43
44 assumeRole(
45 roleArn: string,
46 /**
47 * RAM Policy config object or valid JSON string
48 */
49 policy?: object | string, // TODO: RAM policy type
50 expirationSeconds?: number,
51 session?: string,
52 options?: {
53 timeout: number;
54 /**
55 * ctx param in urllib's request param
56 */
57 ctx: any;
58 },
59 ): Promise<{ credentials: Credentials }>;
60 }
61
62 interface Credentials {
63 /**
64 * STS access key id.
65 */
66 AccessKeyId: string;
67
68 /**
69 * STS access key secret.
70 */
71 AccessKeySecret: string;
72
73 /**
74 * STS token.
75 */
76 SecurityToken: string;
77
78 /**
79 * STS expiration UTC time in ISO format.
80 */
81 Expiration: string;
82 }
83
84 interface STSOptions {
85 /**
86 * Access key id.
87 */
88 accessKeyId: string;
89
90 /**
91 * Access key secret.
92 */
93 accessKeySecret: string;
94 }
95
96 interface Bucket {
97 name: string;
98 region: string;
99 creationDate: string;
100 StorageClass: StorageType;
101 }
102
103 type StorageType = 'Standard' | 'IA' | 'Archive';
104
105 type ACLType = 'public-read-write' | 'public-read' | 'private';
106
107 type HTTPMethods = 'GET' | 'POST' | 'DELETE' | 'PUT';
108
109 type RedundancyType = 'LRS' | 'ZRS';
110
111 interface RequestOptions {
112 // the operation timeout
113 timeout?: number | undefined;
114 }
115
116 type RuleStatusType = 'Enabled' | 'Disabled';
117
118 interface LifecycleRule {
119 /** rule id, if not set, OSS will auto create it with random string. */
120 id?: string | undefined;
121 /** store prefix */
122 prefix: string;
123 /** rule status, allow values: Enabled or Disabled */
124 status: RuleStatusType;
125 /** expire after the days */
126 days?: number | string | undefined;
127 /** expire date, e.g.: 2022-10-11T00:00:00.000Z date and days only set one. */
128 date: string;
129 }
130
131 interface CORSRule {
132 /** configure for Access-Control-Allow-Origin header */
133 allowedOrigin: string | string[];
134 /** configure for Access-Control-Allow-Methods header */
135 allowedMethod: string | string[];
136 /** configure for Access-Control-Allow-Headers header */
137 allowedHeader?: string | string[] | undefined;
138 /** configure for Access-Control-Expose-Headers header */
139 exposeHeader?: string | string[] | undefined;
140 /** configure for Access-Control-Max-Age header */
141 maxAgeSeconds?: string | string[] | undefined;
142 }
143
144 interface OwnerType {
145 id: string;
146 displayName: string;
147 }
148
149 interface ObjectMeta {
150 /** object name on oss */
151 name: string;
152 /** object url */
153 url: string;
154 /** object last modified GMT date, e.g.: 2015-02-19T08:39:44.000Z */
155 lastModified: string;
156 /** object etag contains ", e.g.: "5B3C1A2E053D763E1B002CC607C5A0FE" */
157 etag: string;
158 /** object type, e.g.: Normal */
159 type: string;
160 /** object size, e.g.: 344606 */
161 size: number;
162 storageClass: StorageType;
163 owner?: OwnerType;
164 }
165
166 interface BucketPolicy {
167 Version: string;
168 Statement: Array<{
169 Action: string[];
170 Effect: 'Allow' | 'Deny';
171 Principal: string[];
172 Resource: string[];
173 }>;
174 }
175
176 interface NormalSuccessResponse {
177 /** response status */
178 status: number;
179 /** response headers */
180 /** todo the object in detail */
181 headers: object;
182 /** response size */
183 size: number;
184 /** request total use time (ms) */
185 rt: number;
186 }
187
188 /**
189 * @see x-oss-meta-* in https://help.aliyun.com/document_detail/31978.html for Aliyun user
190 * @see x-oss-meta-* in https://www.alibabacloud.com/help/en/doc-detail/31978.html for AlibabaCloud user
191 */
192 interface UserMeta extends Record<string, string | number> {
193 uid: number;
194 pid: number;
195 }
196
197 interface ObjectCallback {
198 /** After a file is uploaded successfully, the OSS sends a callback request to this URL. */
199 url: string;
200 /** The host header value for initiating callback requests. */
201 host?: string | undefined;
202 /** The value of the request body when a callback is initiated, for example, key=$(key)&etag=$(etag)&my_var=$(x:my_var). */
203 body: string;
204 /** The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value. */
205 contentType?: string | undefined;
206 customValue?: object | undefined;
207 /** extra headers, detail see RFC 2616 */
208 headers?: object | undefined;
209 }
210
211 interface ModifyData {
212 /** object last modified GMT string */
213 lastModified: string;
214 /** object etag contains ", e.g.: "5B3C1A2E053D763E1B002CC607C5A0FE" */
215 etag: string;
216 }
217
218 interface Checkpoint {
219 /** The file object selected by the user, if the browser is restarted, it needs the user to manually trigger the settings */
220 file: any;
221 /** object key */
222 name: string;
223 fileSize: number;
224 partSize: number;
225 uploadId: string;
226 doneParts: Array<{ number: number; etag: string }>;
227 }
228
229 interface ObjectPart {
230 PartNumber: number;
231 /** {Date} Time when a part is uploaded. */
232 LastModified: any;
233 ETag: string;
234 size: number;
235 }
236
237 interface Upload {
238 name: string;
239 uploadId: string;
240 initiated: any;
241 }
242
243 interface Channel {
244 Name: string;
245 Description: string;
246 Status: string;
247 LastModified: string;
248 PublishUrls: string[];
249 PlayUrls: string[];
250 }
251
252 interface ChannelHistory {
253 StartTime: string;
254 EndTime: string;
255 /** the remote addr */
256 RemoteAddr: string;
257 }
258
259 // parameters type
260 interface ListBucketsQueryType {
261 /** search buckets using prefix key */
262 prefix?: string | undefined;
263 /** search start from marker, including marker key */
264 marker?: string | undefined;
265 /** max buckets, default is 100, limit to 1000 */
266 'max-keys'?: string | number | undefined;
267 }
268
269 interface PutBucketOptions {
270 acl: ACLType;
271 dataRedundancyType: RedundancyType;
272 timeout: number;
273 storageClass: StorageType;
274 }
275
276 interface PutBucketWebsiteConfig {
277 /** default page, e.g.: index.html */
278 index: string;
279 /** error page, e.g.: 'error.html' */
280 error?: string | undefined;
281 }
282
283 interface ListObjectsQuery {
284 /** search object using prefix key */
285 prefix?: string | undefined;
286 /** search start from marker, including marker key */
287 marker?: string | undefined;
288 /** only search current dir, not including subdir */
289 delimiter?: string | undefined; // delimiter search scope e.g.
290 /** max objects, default is 100, limit to 1000 */
291 'max-keys': string | number;
292 /** Specifies that the object names in the response are URL-encoded. */
293 'encoding-type'?: 'url' | '';
294 }
295
296 interface ListV2ObjectsQuery {
297 /** search object using prefix key */
298 prefix?: string;
299 /** search start from token, including token key */
300 'continuation-token'?: string;
301 /** only search current dir, not including subdir */
302 delimiter?: string | number;
303 /** max objects, default is 100, limit to 1000 */
304 'max-keys'?: string;
305 /**
306 * The name of the object from which the list operation begins.
307 * If this parameter is specified, objects whose names are alphabetically greater than the start-after parameter value are returned.
308 */
309 'start-after'?: string;
310 /** Specifies whether to include the information about object owners in the response. */
311 'fetch-owner'?: boolean;
312 /** Specifies that the object names in the response are URL-encoded. */
313 'encoding-type'?: 'url' | '';
314 }
315
316 interface ListObjectResult {
317 objects: ObjectMeta[];
318 prefixes: string[];
319 isTruncated: boolean;
320 nextMarker: string;
321 res: NormalSuccessResponse;
322 }
323
324 interface PutObjectOptions {
325 /** the operation timeout */
326 timeout?: number | undefined;
327 /** custom mime, will send with Content-Type entity header */
328 mime?: string | undefined;
329 /** user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 } */
330 meta?: UserMeta | undefined;
331 callback?: ObjectCallback | undefined;
332 headers?: object | undefined;
333 }
334
335 interface PutObjectResult {
336 name: string;
337 url: string;
338 data: object;
339 res: NormalSuccessResponse;
340 }
341
342 interface PutStreamOptions {
343 /** the stream length, chunked encoding will be used if absent */
344 contentLength?: number | undefined;
345 /** the operation timeout */
346 timeout: number;
347 /** custom mime, will send with Content-Type entity header */
348 mime: string;
349 meta: UserMeta;
350 callback: ObjectCallback;
351 headers?: object | undefined;
352 }
353
354 interface AppendObjectOptions {
355 /** specify the position which is the content length of the latest object */
356 position?: string | undefined;
357 /** the operation timeout */
358 timeout?: number | undefined;
359 /** custom mime, will send with Content-Type entity header */
360 mime?: string | undefined;
361 meta?: UserMeta | undefined;
362 headers?: object | undefined;
363 }
364
365 interface AppendObjectResult {
366 name: string;
367 /** the url of oss */
368 url: string;
369 res: NormalSuccessResponse;
370 /** the next position */
371 nextAppendPosition: string;
372 }
373
374 interface HeadObjectOptions {
375 timeout?: number | undefined;
376 headers?: object | undefined;
377 }
378
379 interface HeadObjectResult {
380 /** response status, maybe 200 or 304 */
381 status: number;
382 meta: UserMeta;
383 res: NormalSuccessResponse;
384 }
385
386 interface GetObjectOptions {
387 timeout?: number | undefined;
388 /** The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value. */
389 process?: string | undefined;
390 headers?: object | undefined;
391 }
392
393 interface GetObjectResult {
394 /** file content buffer if file parameter is null or ignore */
395 content?: any;
396 res: NormalSuccessResponse;
397 }
398
399 interface GetStreamOptions {
400 timeout?: number | undefined;
401 /** The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value. */
402 process?: string | undefined;
403 headers?: object | undefined;
404 }
405
406 interface GetStreamResult {
407 /** readable stream instance if response status is not 200, stream will be null. */
408 stream?: any;
409 res: NormalSuccessResponse;
410 }
411
412 interface CopyObjectOptions {
413 timeout?: number | undefined;
414 meta?: UserMeta | undefined;
415 headers?: object | undefined;
416 }
417
418 interface CopyAndPutMetaResult {
419 data: ModifyData;
420 res: NormalSuccessResponse;
421 }
422
423 interface DeleteMultiOptions {
424 /** quite mode or verbose mode, default is false */
425 quiet?: boolean | undefined;
426 timeout?: number | undefined;
427 }
428
429 interface DeleteMultiResult {
430 /** deleted object names list */
431 deleted?: string[] | undefined;
432 res: NormalSuccessResponse;
433 }
434
435 interface ResponseHeaderType {
436 'content-type'?: string | undefined;
437 'content-disposition'?: string | undefined;
438 'cache-control'?: string | undefined;
439 }
440
441 interface SignatureUrlOptions {
442 /** after expires seconds, the url will become invalid, default is 1800 */
443 expires?: number | undefined;
444 /** the HTTP method, default is 'GET' */
445 method?: HTTPMethods | undefined;
446 /** set the request content type */
447 'Content-Type'?: string | undefined;
448 /** image process params, will send with x-oss-process e.g.: {process: 'image/resize,w_200'} */
449 process?: string | undefined;
450 /** traffic limit, range: 819200~838860800 */
451 trafficLimit?: number | undefined;
452 /** additional signature parameters in url */
453 subResource?: object | undefined;
454 /** set the response headers for download */
455 response?: ResponseHeaderType | undefined;
456 /** set the callback for the operation */
457 callback?: ObjectCallback | undefined;
458 }
459
460 interface GetACLResult {
461 acl: ACLType;
462 res: NormalSuccessResponse;
463 }
464
465 interface InitMultipartUploadOptions {
466 timeout?: number | undefined;
467 /** Mime file type */
468 mime?: string | undefined;
469 meta?: UserMeta | undefined;
470 headers?: object | undefined;
471 }
472
473 interface InitMultipartUploadResult {
474 res: { status: number; headers: object; size: number; rt: number };
475 /** bucket name */
476 bucket: string;
477 /** object name store on OSS */
478 name: string;
479 /** upload id, use for uploadPart, completeMultipart */
480 uploadId: string;
481 }
482
483 interface UploadPartResult {
484 name: string;
485 etag: string;
486 res: NormalSuccessResponse;
487 }
488
489 interface CompleteMultipartUploadOptions {
490 timeout?: number | undefined;
491 callback?: ObjectCallback | undefined;
492 headers?: object | undefined;
493 }
494
495 interface CompleteMultipartUploadResult {
496 bucket: string;
497 name: string;
498 etag: string;
499 data: object;
500 res: NormalSuccessResponse;
501 }
502
503 interface MultipartUploadOptions {
504 /** the number of parts to be uploaded in parallel */
505 parallel?: number | undefined;
506 /** the suggested size for each part */
507 partSize?: number | undefined;
508 /** the progress callback called after each successful upload of one part */
509 progress?: ((...args: any[]) => any) | undefined;
510 /** the checkpoint to resume upload, if this is provided, it will continue the upload from where interrupted, otherwise a new multipart upload will be created. */
511 checkpoint?: Checkpoint | undefined;
512 meta?: UserMeta | undefined;
513 mime?: string | undefined;
514 callback?: ObjectCallback | undefined;
515 headers?: object | undefined;
516 timeout?: number | undefined;
517 /** {Object} only uploadPartCopy api used, detail */
518 copyheaders?: object | undefined;
519 }
520
521 interface MultipartUploadResult {
522 bucket: string;
523 name: string;
524 etag: string;
525 data: object;
526 res: NormalSuccessResponse;
527 }
528
529 interface MultipartUploadCopyResult {
530 bucket: string;
531 name: string;
532 etag: string;
533 res: NormalSuccessResponse;
534 }
535
536 interface MultipartUploadCopySourceData {
537 /** the source object name */
538 sourceKey: string;
539 /** sourceData. the source bucket name */
540 sourceBucketName: string;
541 /** data copy start byte offset, e.g: 0 */
542 startOffset: number;
543 /** data copy end byte offset, e.g: 102400 */
544 endOffset: number;
545 }
546
547 interface ListPartsQuery {
548 /** The maximum part number in the response of the OSS. default value: 1000. */
549 'max-parts': number;
550 /** Starting position of a specific list. A part is listed only when the part number is greater than the value of this parameter. */
551 'part-number-marker': number;
552 /** Specify the encoding of the returned content and the encoding type. Optional value: url */
553 'encoding-type': string;
554 }
555
556 interface ListPartsResult {
557 uploadId: string;
558 bucket: string;
559 name: string;
560 PartNumberMarker: number;
561 nextPartNumberMarker: number;
562 maxParts: number;
563 isTruncated: boolean;
564 parts: ObjectPart[];
565 res: NormalSuccessResponse;
566 }
567
568 interface ListUploadsQuery {
569 prefix?: string | undefined;
570 'max-uploads'?: number | undefined;
571 'key-marker'?: string | undefined;
572 'upload-id-marker'?: string | undefined;
573 }
574
575 interface ListUploadsResult {
576 res: NormalSuccessResponse;
577 bucket: string;
578 nextKeyMarker: any;
579 nextUploadIdMarker: any;
580 isTruncated: boolean;
581 uploads: Upload[];
582 }
583
584 interface PutChannelConf {
585 Description?: string | undefined;
586 Status?: string | undefined;
587 Target?: {
588 Type: string;
589 FragDuration: number;
590 FragCount: number;
591 PlaylistName: string;
592 } | undefined;
593 }
594
595 interface PutChannelResult {
596 publishUrls: string[];
597 playUrls: string[];
598 res: NormalSuccessResponse;
599 }
600
601 interface GetChannelResult {
602 Status: string;
603 ConnectedTime?: string | undefined;
604 RemoteAddr?: string | undefined;
605 Video?: object | undefined;
606 Audio?: object | undefined;
607 res: NormalSuccessResponse;
608 }
609
610 interface ListChannelsQuery {
611 /** the channel id prefix (returns channels with this prefix) */
612 prefix: string;
613 /** the channel id marker (returns channels after this id) */
614 marker: string;
615 /** max number of channels to return */
616 'max-keys ': number;
617 }
618
619 interface ListChannelsResult {
620 channels: Channel[];
621 nextMarker: string | null;
622 isTruncated: boolean;
623 res: NormalSuccessResponse;
624 }
625
626 interface ChannelHistoryResult {
627 records: ChannelHistory;
628 res: NormalSuccessResponse;
629 }
630
631 interface GetRtmpUrlOptions {
632 /** the expire time in seconds of the url */
633 expires?: number | undefined;
634 /** the additional parameters for url, e.g.: {playlistName: 'play.m3u8'} */
635 params?: object | undefined;
636 /** the operation timeout */
637 timeout?: number | undefined;
638 }
639
640 interface GetBucketPolicyResult {
641 policy: BucketPolicy | null;
642 status: number;
643 res: NormalSuccessResponse;
644 }
645
646 interface PostObjectParams {
647 policy: string;
648 OSSAccessKeyId: string;
649 Signature: string;
650 }
651}
652
653// cluster
654declare namespace OSS {
655 interface ClusterType {
656 host: string;
657 accessKeyId: string;
658 accessKeySecret: string;
659 }
660
661 interface ClusterOptions {
662 clusters: ClusterType[];
663 schedule?: string | undefined;
664 }
665
666 class ClusterClient {
667 constructor(options: ClusterOptions);
668
669 list(query: ListObjectsQuery | null, options: RequestOptions): Promise<ListObjectResult>;
670
671 /**
672 * @since 6.12.0
673 */
674 listV2(query: ListV2ObjectsQuery | null, options?: RequestOptions): Promise<ListObjectResult>;
675
676 put(name: string, file: any, options?: PutObjectOptions): Promise<PutObjectResult>;
677
678 putStream(
679 name: string,
680 stream: any,
681 options?: PutStreamOptions,
682 ): Promise<{ name: string; res: NormalSuccessResponse }>;
683
684 head(name: string, options?: HeadObjectOptions): Promise<HeadObjectResult>;
685
686 get(name: string, file?: any, options?: GetObjectOptions): Promise<GetObjectResult>;
687
688 getStream(name?: string, options?: GetStreamOptions): Promise<GetStreamResult>;
689
690 delete(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
691
692 copy(name: string, sourceName: string, options?: CopyObjectOptions): Promise<CopyAndPutMetaResult>;
693
694 putMeta(name: string, meta: UserMeta, options: RequestOptions): Promise<CopyAndPutMetaResult>;
695
696 deleteMulti(names: string[], options?: DeleteMultiOptions): Promise<DeleteMultiResult>;
697
698 signatureUrl(name: string, options?: SignatureUrlOptions): string;
699
700 asyncSignatureUrl(name: string, options?: SignatureUrlOptions): Promise<string>;
701
702 putACL(name: string, acl: ACLType, options?: RequestOptions): Promise<NormalSuccessResponse>;
703
704 restore(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
705 }
706}
707
708// image
709declare namespace OSS {
710 interface ImageClientOptions {
711 /** your image service domain that binding to a OSS bucket */
712 imageHost: string;
713 /** access key you create on aliyun console website */
714 accessKeyId: string;
715 /** access secret you create */
716 accessKeySecret: string;
717 /** the default bucket you want to access If you don't have any bucket, please use putBucket() create one first. */
718 bucket: string;
719 /** the bucket data region location, please see Data Regions, default is oss-cn-hangzhou */
720 region?: string | undefined;
721 /** 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. */
722 internal?: boolean | undefined;
723 /** instance level timeout for all operations, default is 60s */
724 timeout?: string | number | undefined;
725 }
726
727 interface ImageGetOptions {
728 timeout?: number | undefined;
729 headers?: object | undefined;
730 }
731
732 interface StyleData {
733 /** style name */
734 Name: string;
735 /** style content */
736 Content: string;
737 /** style create time */
738 CreateTime: string;
739 /** style last modify time */
740 LastModifyTime: string;
741 }
742
743 class ImageClient {
744 constructor(options: ImageClientOptions);
745
746 /**
747 * Get an image from the image channel.
748 */
749 get(name: string, file?: any, options?: ImageGetOptions): Promise<{ content: any; res: NormalSuccessResponse }>;
750
751 /**
752 * Get an image read stream.
753 */
754 getStream(name: string, options?: ImageGetOptions): Promise<{ stream: any; res: NormalSuccessResponse }>;
755
756 /**
757 * Get a image exif info by image object name from the image channel.
758 */
759 getExif(name: string, options?: RequestOptions): Promise<{ data: object; res: NormalSuccessResponse }>;
760
761 /**
762 * Get a image info and exif info by image object name from the image channel.
763 */
764 getInfo(name: string, options?: RequestOptions): Promise<{ data: object; res: NormalSuccessResponse }>;
765
766 /**
767 * todo
768 */
769 putStyle(
770 name: string,
771 style: string,
772 options?: RequestOptions,
773 ): Promise<{ data: object; res: NormalSuccessResponse }>;
774
775 /**
776 * Get a style by name from the image channel.
777 */
778 getStyle(name: string, options?: RequestOptions): Promise<{ data: StyleData; res: NormalSuccessResponse }>;
779
780 /**
781 * Get all styles from the image channel.
782 */
783 listStyle(options?: RequestOptions): Promise<StyleData[]>;
784
785 /**
786 * todo
787 */
788 deleteStyle(styleName: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
789
790 /**
791 * Create a signature url for directly download.
792 */
793 signatureUrl(name: string, options?: { expires?: string | undefined; timeout?: string | undefined }): string;
794
795 /**
796 * Basically the same as signatureUrl, if refreshSTSToken is configured asyncSignatureUrl will refresh stsToken
797 */
798 asyncSignatureUrl(name: string, options?: SignatureUrlOptions): Promise<string>;
799 }
800}
801
802declare class OSS {
803 constructor(options: OSS.Options);
804
805 /******************************************* the bucket operations *************************************************/
806
807 // base operators
808 /**
809 * List buckets in this account.
810 */
811 listBuckets(query: OSS.ListBucketsQueryType | null, options?: OSS.RequestOptions): Promise<OSS.Bucket[]>;
812
813 /**
814 * Create a new bucket.
815 */
816 putBucket(
817 name: string,
818 options?: OSS.PutBucketOptions,
819 ): Promise<{ bucket: string; res: OSS.NormalSuccessResponse }>;
820
821 /**
822 * Use the bucket.
823 */
824 useBucket(name: string): void;
825
826 /**
827 * Delete an empty bucket.
828 */
829 deleteBucket(name: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
830
831 /**
832 * Get bucket information,include CreationDateExtranetEndpointIntranetEndpointLocationNameStorageClassOwnerAccessControlList
833 */
834 getBucketInfo(name: string): Promise<any>;
835
836 /**
837 * Get bucket location
838 */
839 getBucketLocation(name: string): Promise<any>;
840
841 // ACL operations
842 /**
843 * Update the bucket ACL.
844 */
845 putBucketACL(name: string, acl: OSS.ACLType, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
846
847 /**
848 * Get the bucket ACL.
849 * acl - acl settings string
850 */
851 getBucketACL(name: string, options?: OSS.RequestOptions): Promise<{ acl: string; res: OSS.NormalSuccessResponse }>;
852
853 // logging operations
854 /**
855 * Update the bucket logging settings. Log file will create every one hour and name format: <prefix><bucket>-YYYY-mm-DD-HH-MM-SS-UniqueString.
856 */
857 putBucketLogging(name: string, prefix?: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
858
859 /**
860 * Get the bucket logging settings.
861 */
862 getBucketLogging(
863 name: string,
864 options?: OSS.RequestOptions,
865 ): Promise<{ enable: boolean; prefix: string | null; res: OSS.NormalSuccessResponse }>;
866
867 /**
868 * Delete the bucket logging settings.
869 */
870 deleteBucketLogging(name: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
871
872 // Website operations
873 /**
874 * Set the bucket as a static website.
875 */
876 putBucketWebsite(name: string, config: OSS.PutBucketWebsiteConfig): Promise<OSS.NormalSuccessResponse>;
877
878 /**
879 * Get the bucket website config.
880 */
881 getBucketWebsite(
882 name: string,
883 options?: OSS.RequestOptions,
884 ): Promise<{ index: string; error: string; res: OSS.NormalSuccessResponse }>;
885
886 /**
887 * Delete the bucket website config.
888 */
889 deleteBucketWebsite(name: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
890
891 // referer operations
892 /**
893 * Set the bucket request Referer white list.
894 */
895 putBucketReferer(
896 name: string,
897 allowEmpty: boolean,
898 referers: string[],
899 options?: OSS.RequestOptions,
900 ): Promise<OSS.NormalSuccessResponse>;
901
902 /**
903 * Get the bucket request Referer white list.
904 */
905 getBucketReferer(
906 name: string,
907 options?: OSS.RequestOptions,
908 ): Promise<{ allowEmpty: boolean; referers: string[]; res: OSS.NormalSuccessResponse }>;
909
910 /**
911 * Delete the bucket request Referer white list.
912 */
913 deleteBucketReferer(name: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
914
915 // lifecycle operations
916 /**
917 * Set the bucket object lifecycle.
918 */
919 putBucketLifecycle(
920 name: string,
921 rules: OSS.LifecycleRule[],
922 options?: OSS.RequestOptions,
923 ): Promise<OSS.NormalSuccessResponse>;
924
925 /**
926 * Get the bucket object lifecycle.
927 */
928 getBucketLifecycle(
929 name: string,
930 options?: OSS.RequestOptions,
931 ): Promise<{ rules: OSS.LifecycleRule[]; res: OSS.NormalSuccessResponse }>;
932
933 /**
934 * Delete the bucket object lifecycle.
935 */
936 deleteBucketLifecycle(name: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
937
938 // CORS operations
939 /**
940 * Set CORS rules of the bucket object
941 */
942 putBucketCORS(
943 name: string,
944 rules: OSS.CORSRule[],
945 options?: OSS.RequestOptions,
946 ): Promise<OSS.NormalSuccessResponse>;
947
948 /**
949 * Get CORS rules of the bucket object.
950 */
951 getBucketCORS(name: string): Promise<{ rules: OSS.CORSRule[]; res: OSS.NormalSuccessResponse }>;
952
953 /**
954 * Delete CORS rules of the bucket object.
955 */
956 deleteBucketCORS(name: string): Promise<OSS.NormalSuccessResponse>;
957
958 // policy operations
959 /**
960 * Adds or modify policy for a bucket.
961 */
962 putBucketPolicy(
963 name: string,
964 policy: OSS.BucketPolicy,
965 options?: OSS.RequestOptions
966 ): Promise<{
967 status: number,
968 res: OSS.NormalSuccessResponse,
969 }>;
970
971 /**
972 * Obtains the policy for a bucket.
973 */
974 getBucketPolicy(name: string, options?: OSS.RequestOptions): Promise<OSS.GetBucketPolicyResult>;
975
976 /**
977 * Deletes the policy added for a bucket.
978 */
979 deleteBucketPolicy(
980 name: string,
981 options?: OSS.RequestOptions
982 ): Promise<{
983 status: number,
984 res: OSS.NormalSuccessResponse,
985 }>;
986
987 /********************************************************** Object operations ********************************************/
988 /**
989 * List objects in the bucket.
990 */
991 list(query: OSS.ListObjectsQuery | null, options: OSS.RequestOptions): Promise<OSS.ListObjectResult>;
992
993 /**
994 * List Objects in the bucket.(V2)
995 */
996 listV2(query: OSS.ListV2ObjectsQuery | null, options: OSS.RequestOptions): Promise<OSS.ListObjectResult>;
997
998 /**
999 * Add an object to the bucket.
1000 */
1001 put(name: string, file: any, options?: OSS.PutObjectOptions): Promise<OSS.PutObjectResult>;
1002
1003 /**
1004 * Add a stream object to the bucket.
1005 */
1006 putStream(
1007 name: string,
1008 stream: any,
1009 options?: OSS.PutStreamOptions,
1010 ): Promise<{ name: string; res: OSS.NormalSuccessResponse }>;
1011
1012 /**
1013 * Append an object to the bucket, it's almost same as put, but it can add content to existing object rather than override it.
1014 */
1015 append(name: string, file: any, options?: OSS.AppendObjectOptions): Promise<OSS.AppendObjectResult>;
1016
1017 /**
1018 * Get the Object url. If provide baseUrl, will use baseUrl instead the default endpoint.
1019 */
1020 getObjectUrl(name: string, baseUrl?: string): string;
1021
1022 /**
1023 * Get the Object url. If provide baseUrl, will use baseUrl instead the default bucket and endpoint. Suggest use generateObjectUrl instead of getObjectUrl.
1024 */
1025 generateObjectUrl(name: string, baseUrl?: string): string;
1026
1027 /**
1028 * Head an object and get the meta info.
1029 */
1030 head(name: string, options?: OSS.HeadObjectOptions): Promise<OSS.HeadObjectResult>;
1031
1032 /**
1033 * Get an object from the bucket.
1034 */
1035 get(name: string, file?: any, options?: OSS.GetObjectOptions): Promise<OSS.GetObjectResult>;
1036
1037 /**
1038 * Get an object read stream.
1039 */
1040 getStream(name?: string, options?: OSS.GetStreamOptions): Promise<OSS.GetStreamResult>;
1041
1042 /**
1043 * Delete an object from the bucket.
1044 */
1045 delete(name: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
1046
1047 /**
1048 * Copy an object from sourceName to name.
1049 */
1050 copy(name: string, sourceName: string, options?: OSS.CopyObjectOptions): Promise<OSS.CopyAndPutMetaResult>;
1051 copy(name: string, sourceName: string, sourceBucket?: string, options?: OSS.CopyObjectOptions): Promise<OSS.CopyAndPutMetaResult>;
1052
1053 /**
1054 * Set an exists object meta.
1055 */
1056 putMeta(name: string, meta: OSS.UserMeta, options: OSS.RequestOptions): Promise<OSS.CopyAndPutMetaResult>;
1057
1058 /**
1059 * Delete multi objects in one request.
1060 */
1061 deleteMulti(names: string[], options?: OSS.DeleteMultiOptions): Promise<OSS.DeleteMultiResult>;
1062
1063 /**
1064 * Create a signature url for download or upload object. When you put object with signatureUrl ,you need to pass Content-Type.Please look at the example.
1065 */
1066 signatureUrl(name: string, options?: OSS.SignatureUrlOptions): string;
1067
1068 /**
1069 * Basically the same as signatureUrl, if refreshSTSToken is configured asyncSignatureUrl will refresh stsToken
1070 */
1071 asyncSignatureUrl(name: string, options?: OSS.SignatureUrlOptions): Promise<string>;
1072
1073 /**
1074 * Set object's ACL.
1075 */
1076 putACL(name: string, acl: OSS.ACLType, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
1077
1078 /**
1079 * Get object's ACL.
1080 */
1081 getACL(name: string, options?: OSS.RequestOptions): Promise<OSS.GetACLResult>;
1082
1083 /**
1084 * Restore Object.
1085 */
1086 restore(name: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
1087
1088 /**
1089 * multi upload
1090 */
1091 initMultipartUpload(name: string, options?: OSS.InitMultipartUploadOptions): Promise<OSS.InitMultipartUploadResult>;
1092
1093 /**
1094 * After initiating a Multipart Upload event, you can upload data in parts based on the specified object name and Upload ID.
1095 */
1096 uploadPart(
1097 name: string,
1098 uploadId: string,
1099 partNo: number,
1100 file: any,
1101 start: number,
1102 end: number,
1103 options?: OSS.RequestOptions,
1104 ): Promise<OSS.UploadPartResult>;
1105
1106 /**
1107 * Using Upload Part Copy, you can copy data from an existing object and upload a part of the data.
1108 * When copying a file larger than 1 GB, you must use the Upload Part Copy method. If you want to copy a file smaller than 1 GB, see Copy Object.
1109 */
1110 uploadPartCopy(
1111 name: string,
1112 uploadId: string,
1113 partNo: number,
1114 range: string,
1115 sourceData: { sourceKey: string; sourceBucketName: string },
1116 options: { timeout?: number | undefined; headers?: object | undefined },
1117 ): Promise<OSS.UploadPartResult>;
1118
1119 /**
1120 * After uploading all data parts, you must call the Complete Multipart Upload API to complete Multipart Upload for the entire file.
1121 */
1122 completeMultipartUpload(
1123 name: string,
1124 uploadId: string,
1125 parts: Array<{ number: number; etag: string }>,
1126 options?: OSS.CompleteMultipartUploadOptions,
1127 ): Promise<OSS.CompleteMultipartUploadResult>;
1128
1129 /**
1130 * Upload file with OSS multipart.
1131 */
1132 multipartUpload(name: string, file: any, options: OSS.MultipartUploadOptions): Promise<OSS.MultipartUploadResult>;
1133
1134 /**
1135 * Copy file with OSS multipart.
1136 * this function contains head, initMultipartUpload, uploadPartCopy, completeMultipartUpload.
1137 * When copying a file larger than 1 GB, you should use the Upload Part Copy method. If you want to copy a file smaller than 1 GB, see Copy Object.
1138 */
1139 multipartUploadCopy(
1140 name: string,
1141 sourceData: OSS.MultipartUploadCopySourceData,
1142 options?: OSS.MultipartUploadOptions,
1143 ): Promise<OSS.MultipartUploadCopyResult>;
1144
1145 /**
1146 * The ListParts command can be used to list all successfully uploaded parts mapped to a specific upload ID, i.e.: those not completed and not aborted.
1147 */
1148 listParts(
1149 name: string,
1150 uploadId: string,
1151 query?: OSS.ListPartsQuery,
1152 options?: OSS.RequestOptions,
1153 ): Promise<OSS.ListPartsResult>;
1154
1155 /**
1156 * List on-going multipart uploads, i.e.: those not completed and not aborted.
1157 */
1158 listUploads(query: OSS.ListUploadsQuery, options?: OSS.RequestOptions): Promise<OSS.ListUploadsResult>;
1159
1160 /**
1161 * Abort a multipart upload for object.
1162 */
1163 abortMultipartUpload(
1164 name: string,
1165 uploadId: string,
1166 options?: OSS.RequestOptions,
1167 ): Promise<OSS.NormalSuccessResponse>;
1168
1169 /**
1170 * get postObject params.
1171 */
1172 calculatePostSignature(
1173 /**
1174 * policy config object or JSON string
1175 */
1176 policy: object | string
1177 ): OSS.PostObjectParams;
1178
1179 /************************************************ RTMP Operations *************************************************************/
1180 /**
1181 * Create a live channel.
1182 */
1183 putChannel(id: string, conf: OSS.PutChannelConf, options?: OSS.RequestOptions): Promise<OSS.PutChannelResult>;
1184
1185 /**
1186 * Get live channel info.
1187 */
1188 getChannel(
1189 id: string,
1190 options?: OSS.RequestOptions,
1191 ): Promise<{ data: OSS.PutChannelConf; res: OSS.NormalSuccessResponse }>;
1192
1193 /**
1194 * Delete a live channel.
1195 */
1196 deleteChannel(id: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
1197
1198 /**
1199 * Change the live channel status.
1200 */
1201 putChannelStatus(id: string, status?: string, options?: OSS.RequestOptions): Promise<OSS.NormalSuccessResponse>;
1202
1203 /**
1204 * Get the live channel status.
1205 */
1206 getChannelStatus(id: string, options?: OSS.RequestOptions): Promise<OSS.GetChannelResult>;
1207
1208 /**
1209 * List channels.
1210 */
1211 listChannels(query: OSS.ListChannelsQuery, options?: OSS.RequestOptions): Promise<OSS.ListChannelsResult>;
1212
1213 /**
1214 * Get the live channel history.
1215 */
1216 getChannelHistory(id: string, options?: OSS.RequestOptions): Promise<OSS.ChannelHistoryResult>;
1217
1218 /**
1219 * Create a VOD playlist for the channel.
1220 */
1221 createVod(
1222 id: string,
1223 name: string,
1224 time: { startTime: number; endTime: number },
1225 options?: OSS.RequestOptions,
1226 ): Promise<OSS.NormalSuccessResponse>;
1227
1228 /**
1229 * Get signatured rtmp url for publishing.
1230 */
1231 getRtmpUrl(channelId?: string, options?: OSS.GetRtmpUrlOptions): string;
1232}
1233
\No newline at end of file