oak-external-sdk/es/service/ali/Ali.d.ts

170 lines
5.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ALiYunZone } from '../../types/ALiYun';
import OSS from 'ali-oss';
export declare class ALiYunInstance {
private accessKey;
private secretKey;
constructor(accessKey: string, secretKey: string);
getUploadInfo(bucket: string, zone: ALiYunZone, key?: string): {
key: string | undefined;
accessKey: string;
policy: string;
signature: string;
uploadHost: string;
bucket: string;
};
private getSignInfo;
removeFile(srcBucket: string, zone: ALiYunZone, srcKey: string): Promise<OSS.DeleteResult>;
isExistObject(srcBucket: string, zone: ALiYunZone, srcKey: string): Promise<boolean>;
/**
* 初始化分片上传
* https://help.aliyun.com/zh/oss/developer-reference/initiate-a-multipart-upload-task
*/
initiateMultipartUpload(bucket: string, zone: ALiYunZone, key: string, options?: {
headers?: Record<string, string>;
timeout?: number;
stsToken?: string;
accessKeyId?: string;
accessKeySecret?: string;
}): Promise<{
uploadId: string;
bucket: string;
name: string;
}>;
/**
* 为分片上传生成预签名 URL
* @param bucket 桶
* @param key 对象键
* @param uploadId 上传 ID
* @param from 起始分片号
* @param to 结束分片号
* @param options 配置项
* @returns 分片预签名 URL 列表
*/
presignMulti(bucket: string, zone: ALiYunZone, key: string, uploadId: string, from: number, to: number, options?: {
expires?: number;
headers?: Record<string, string>;
timeout?: number;
stsToken?: string;
accessKeyId?: string;
accessKeySecret?: string;
}): Promise<{
partNumber: number;
uploadUrl: string;
}[]>;
/**
* 准备分片上传初始化并生成所有分片的预签名URL
* 用于前端直传场景,返回 uploadId 和每个分片的上传 URL
*/
prepareMultipartUpload(bucket: string, zone: ALiYunZone, key: string, partCount: number, options?: {
expires?: number;
headers?: Record<string, string>;
timeout?: number;
stsToken?: string;
accessKeyId?: string;
accessKeySecret?: string;
}): Promise<{
uploadId: string;
parts: {
partNumber: number;
uploadUrl: string;
}[];
}>;
/**
* 上传分片
* https://help.aliyun.com/zh/oss/developer-reference/upload-parts
*/
uploadPart(bucket: string, zone: ALiYunZone, key: string, uploadId: string, partNumber: number, file: any, start?: number, end?: number, options?: {
timeout?: number;
stsToken?: string;
accessKeyId?: string;
accessKeySecret?: string;
}): Promise<{
etag: string;
name: string;
}>;
/**
* 完成分片上传
* https://help.aliyun.com/zh/oss/developer-reference/complete-a-multipart-upload-task
*/
completeMultipartUpload(bucket: string, zone: ALiYunZone, key: string, uploadId: string, parts: Array<{
number: number;
etag: string;
}>, options?: {
headers?: Record<string, string>;
timeout?: number;
stsToken?: string;
}): Promise<{
bucket: string;
name: string;
etag: string;
}>;
/**
* 取消分片上传
* https://help.aliyun.com/zh/oss/developer-reference/abort-a-multipart-upload-task
*/
abortMultipartUpload(bucket: string, zone: ALiYunZone, key: string, uploadId: string, options?: {
timeout?: number;
stsToken?: string;
}): Promise<void>;
/**
* 列举已上传的分片
* https://help.aliyun.com/zh/oss/developer-reference/list-uploaded-parts
*/
listParts(bucket: string, zone: ALiYunZone, key: string, uploadId: string, options?: {
'max-parts'?: number;
'part-number-marker'?: number;
stsToken?: string;
}): Promise<{
parts: {
partNumber: any;
lastModified: any;
etag: any;
size: any;
}[];
nextPartNumberMarker: number;
isTruncated: boolean;
}>;
/**
* 列举所有执行中的分片上传任务
* https://help.aliyun.com/zh/oss/developer-reference/list-initiated-multipart-upload-tasks
*/
listMultipartUploads(bucket: string, zone: ALiYunZone, options?: {
prefix?: string;
'max-uploads'?: number;
'key-marker'?: string;
'upload-id-marker'?: string;
stsToken?: string;
}): Promise<{
uploads: {
name: any;
uploadId: any;
initiated: any;
}[];
nextKeyMarker: any;
nextUploadIdMarker: any;
isTruncated: boolean;
}>;
/**
* 获取签名URL
* https://help.aliyun.com/zh/oss/developer-reference/authorize-access-4
*/
getSignedUrl(bucket: string, zone: ALiYunZone, key: string, options?: {
expires?: number;
method?: 'GET' | 'PUT' | 'DELETE' | 'POST';
process?: string;
response?: Record<string, string>;
}): Promise<string>;
/**
* 获取预签名对象URL统一接口
*/
presignObjectUrl(method: 'GET' | 'PUT' | 'POST' | 'DELETE', bucket: string, zone: ALiYunZone, key: string, options?: {
expires?: number;
process?: string;
response?: Record<string, string>;
}): Promise<{
url: string;
headers?: Record<string, string | string[]>;
formdata?: Record<string, any>;
}>;
}