更新记录
1.0.0(2025-06-26)
初始版本
平台兼容性
uni-app(4.26)
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
√ |
√ |
- |
- |
√ |
√ |
√ |
√ |
- |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(4.26)
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
√ |
√ |
- |
- |
yzc-aliyun-oss 封装阿里云OSS插件,目前仅支持简单上传下载,其他功能待后续完善(需要打自定义基座,请测试合适后再购买)
注意:相关参数见yzc-aliyun-oss/utssdk/interface.uts,具体参考阿里云oss官网
uniappx使用
导入头文件
import {
AliyunOSSManager,
OSSClientInitInfoType,
OSSClientConfigurationType,
PutObjectRequestType,
PutObjectRequestTypeOptions,
OSSGetObjectResultType,
GetObjectRequestType,
GetObjectRequestTypeOptions,
} from '@/uni_modules/yzc-aliyun-oss';
初始化(以下两种方式根据实际情况选择)
// 方式1
AliyunOSSManager.setupDefalutOSSClient({
url: "http://xxxx",
endPoint: "http://xxxx",
region: "xxxx"
} as OSSClientInitInfoType, {
maxRetryCount: 3
} as OSSClientConfigurationType)
// 方式2
AliyunOSSManager.setupDefalutOSSClient({
endPoint: "http://xxxx",
region: "xxxx",
accessKeyId: "xxxx",
accessKeySecret: "xxxx",
securityToken: "xxxx"
} as OSSClientInitInfoType, {
maxRetryCount: 3
} as OSSClientConfigurationType)
上传
// 通过路径
let filePath = "xxxx" // 这里需要给一个路径
AliyunOSSManager.upload({
put: {
bucketName: 'examplebucket',
objectKey: 'exampledir/exampleobject.txt',
uploadingFilePath: filePath,
} as PutObjectRequestType,
waitUntilFinished: false,
uploadRetryCallback:() => {
console.log('uploadRetryCallback')
},
progressCallBack: (totalBytesSent: number, totalBytesExpectedToSend: number) => {
},
completeCallBack: (success: boolean, errorCode: number | null, errorMsg: string | null) => {
console.log(success, errorCode, errorMsg)
}
} as PutObjectRequestTypeOptions)
// 通过文件转base64
let filePath = "xxxx" // 这里需要给一个转换后的base64字符串
AliyunOSSManager.upload({
put: {
bucketName: 'examplebucket',
objectKey: 'exampledir/exampleobject.txt',
uploadingData_Base64Str: base64
} as PutObjectRequestType,
waitUntilFinished: false,
uploadRetryCallback:() => {
console.log('uploadRetryCallback')
},
progressCallBack: (totalBytesSent: number, totalBytesExpectedToSend: number) => {
},
completeCallBack: (success: boolean, errorCode: number | null, errorMsg: string | null) => {
console.log(success, errorCode, errorMsg)
}
} as PutObjectRequestTypeOptions)
下载
AliyunOSSManager.download({
get: {
bucketName: 'examplebucket',
objectKey: 'exampledir/exampleobject.txt'
} as GetObjectRequestType,
waitUntilFinished: false,
progressCallBack: (totalBytesWritten: number, totalBytesExpectedToWrite: number) => {
},
completeCallBack: (success: boolean, result: OSSGetObjectResultType | null, errorCode: number | null, errorMsg: string | null) => {
console.log(success, result, errorCode, errorMsg)
}
} as GetObjectRequestTypeOptions)
uniapp使用
导入头文件
import { AliyunOSSManager } from '@/uni_modules/yzc-aliyun-oss';
初始化(以下两种方式根据实际情况选择)
// 方式1
AliyunOSSManager.setupDefalutOSSClient({
url: "http://xxxx",
endPoint: "http://xxxx",
region: "xxxx"
}, {
maxRetryCount: 3
})
// 方式2
AliyunOSSManager.setupDefalutOSSClient({
endPoint: "http://xxxx",
region: "xxxx",
accessKeyId: "xxxx",
accessKeySecret: "xxxx",
securityToken: "xxxx"
}, {
maxRetryCount: 3
})
上传
// 通过路径
let filePath = "xxxx" // 这里需要给一个路径
AliyunOSSManager.upload({
put: {
bucketName: 'examplebucket',
objectKey: 'exampledir/exampleobject.txt',
uploadingFilePath: filePath,
},
waitUntilFinished: false,
uploadRetryCallback:() => {
console.log('uploadRetryCallback')
},
progressCallBack: (totalBytesSent, totalBytesExpectedToSend) => {
},
completeCallBack: (success, errorCode, errorMsg) => {
console.log(success, errorCode, errorMsg)
}
})
// 通过文件转base64
let filePath = "xxxx" // 这里需要给一个转换后的base64字符串
AliyunOSSManager.upload({
put: {
bucketName: 'examplebucket',
objectKey: 'exampledir/exampleobject.txt',
uploadingData_Base64Str: base64
},
waitUntilFinished: false,
uploadRetryCallback:() => {
console.log('uploadRetryCallback')
},
progressCallBack: (totalBytesSent, totalBytesExpectedToSend) => {
},
completeCallBack: (success, errorCode, errorMsg) => {
console.log(success, errorCode, errorMsg)
}
})
下载
AliyunOSSManager.download({
get: {
bucketName: 'examplebucket',
objectKey: 'exampledir/exampleobject.txt'
},
waitUntilFinished: false,
progressCallBack: (totalBytesWritten, totalBytesExpectedToWrite) => {
},
completeCallBack: (success, result, errorCode, errorMsg) => {
console.log(success, result, errorCode, errorMsg)
}
})