UNPKG

@minto-ai/aws-obs-server

Version:

亚马逊OBS文件上传

65 lines (64 loc) 1.7 kB
import { IUploadFileSuccessFile } from './upload'; /** * OBS全局配置 */ interface IGlobalOptions { /** * 用于获取上传所需的 token,该 token 用于身份验证,确保上传请求的合法性。 */ readonly getToken: () => string; /** * 单文件上传和分片上传的文件大小分隔线,单位为字节,默认为 5MB(即 1024 * 1024 * 5)。当文件大小超过该阈值时,将使用分片上传;否则使用单文件上传。 */ fileSplitThreshold?: number; } /** * 上传选项接口 */ interface IUploadOptions { /** * 要上传的文件。 */ sourceFile: File; /** * 文件分片大小,单位为字节。 * 默认为5MB。 */ partSize?: number; /** * 上传开始的回调函数 */ onStart?: () => void; /** * 上传进度回调 * @param event - 包含上传进度信息的对象 * @param event.percent - 上传进度百分比 */ onProgress?: (event: { percent: number; }) => void; /** * 上传完成回调 * @param event - 包含上传结果信息的对象 * @param event.sourceFile - 文件对象 * @param event.fileInfo - 文件上传目录 */ onSuccess?: (event: { sourceFile: File; fileInfo: IUploadFileSuccessFile; }) => void; /** * 上传失败回调 * @param error - 错误对象 */ onError?: (error: Error) => void; /** * 取消上传回调 */ onAbort?: () => void; /** * 上传结束回调,无论成功或失败都会触发 */ onFinally?: () => void; } export type { IGlobalOptions, IUploadOptions };