Skip to content

Commit

Permalink
upd:补充index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
livehigh committed Jun 10, 2021
1 parent 4414530 commit 6d5999f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,7 @@ function uploadFile() {
Region: config.Region,
Key: filename,
Body: blob,
SliceSize: 1024 * 1024 * 5, // 大于5mb才进行分块上传
onProgress: function (info) {
var percent = Math.floor(info.percent * 10000) / 100;
var speed = Math.floor(info.speed / 1024 / 1024 * 100) / 100;
Expand Down
33 changes: 32 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,33 @@ Bulk:批量模式,恢复时间为24 - 48小时。 */
}[],
}

// uploadFile 高级上传

interface FileFinishInfo {
err: Error;
data: UploadFileItemResult;
options: UploadFileItemParams;
}
type onFileFinish = (params: FileFinishInfo) => void;

type UploadFileParams = (PutObjectParams | SliceUploadFileParams) & {
/** 要上传的本地文件路径 */
Body: UploadBody,
/** 使用 uploadFile 高级上传时,文件大小大于该数值将使用按分块上传,否则将调用简单上传,单位 Byte,默认值1048576(1MB) */
SliceSize?: number,
/** 上传的进度回调方法 */
onProgress?: onProgress,
/** 上传完成回调方法 */
onFileFinish?: onFileFinish,
}

interface UploadFileResult extends GeneralResult {
/** 文件上传错误信息 */
error: Error,
/** 文件上传成功信息 */
data: UploadFileItemResult,
}

// sliceCopyFile
/** sliceCopyFile 接口参数 */
interface SliceCopyFileParams extends ObjectParams {
Expand Down Expand Up @@ -2119,7 +2146,11 @@ declare class COS {
abortUploadTask(params: COS.AbortUploadTaskParams, callback: (err: COS.CosError, data: COS.AbortUploadTaskResult) => void): void;
abortUploadTask(params: COS.AbortUploadTaskParams): Promise<COS.AbortUploadTaskResult>;

/** 分片复制文件 */
/** 高级上传文件 */
uploadFile(params: COS.UploadFileParams, callback: (err: COS.CosError, data: COS.UploadFileResult) => void): void;
uploadFile(params: COS.UploadFileParams): Promise<COS.UploadFileResult>;

/** 批量上传文件 */
uploadFiles(params: COS.UploadFilesParams, callback: (err: COS.CosError, data: COS.UploadFilesResult) => void): void;
uploadFiles(params: COS.UploadFilesParams): Promise<COS.UploadFilesResult>;

Expand Down

0 comments on commit 6d5999f

Please sign in to comment.