在微信小程序开发工具中调用云函数上传文件到七牛云扩展存储时,调用uploadFile会报错 Error: Parameter sk is required。 到七牛云官网找到sk和ak,以及在DCloud后台里面开发者参数的bucketName,加到在uniCloud.getExtStorageManager中,又会报错 errCode: 631, errMsg: 'no such bucket' ,换成DClound后台里面开发者参数的bucketSecret,又会报错:uploadResult: { errCode: 401, errMsg: 'bad token' 。
请问大神们,这种情况,应该怎么调用uploadFile上传到扩展存储?
云函数如下
const extStorageManager = uniCloud.getExtStorageManager({
provider: "qiniu",
domain: "example.com", // 域名地址
});
const { fileName, fileContent, openid } = body;
const cloudPath = `Avatar/${openid}_${fileName}`;
const uploadResult = await extStorageManager.uploadFile({
cloudPath:cloudPath,
fileContent: Buffer.from(fileContent, 'base64'),
allowUpdate: false,
});
console.log('uploadFile: ', res);
1 个回复
DCloud_uniCloud_VK
相同帖子:https://ask.dcloud.net.cn/question/207563?item_id=295767&rf=false