ARMS微信小程序配置了dirve 跟 os,上传的时候没有显示可能是因为以下原因:
1、未正确安装和配置依赖库
2、配置文件中未正确设置相关参数
3、代码中未正确调用相关API
针对以上原因,可以尝试以下解决方案:
1、使用npm安装依赖库
npm install save alioss
npm install save alidrive
2、在项目根目录下的package.json
文件中添加如下配置:
{
"dependencies": {
"alioss": "^6.0.0",
"alidrive": "^1.0.0"
}
}
1、在app.json
或app.wxss
文件中添加如下配置:
{
"usingComponents": {},
"requiredBackgroundModes": ["audio"],
"plugins": {
"dirve": {
"version": "1.0.0",
"provider": "wx2b03c6e691cd7370"
},
"oss": {
"version": "1.0.0",
"provider": "wx2b03c6e691cd7370"
}
}
}
1、在需要使用dirve和oss的地方引入相关模块:
const drive = require('alidrive');
const oss = require('alioss');
2、使用相关API进行操作,
// 使用dirve API上传文件到阿里云盘
drive.upload({
filePath: 'path/to/your/file', // 文件路径
remoteDir: 'your_remote_directory', // 远程目录
}).then(res => {
console.log('上传成功', res);
}).catch(err => {
console.error('上传失败', err);
});
// 使用oss API上传文件到阿里云OSS服务器
oss.putFile({
key: 'your_object_key', // OSS对象键名(即文件名)
localFilePath: 'path/to/your/local/file', // 本地文件路径
}).then(res => {
console.log('上传成功', res);
}).catch(err => {
console.error('上传失败', err);
});