阿里云oss上传图片报错,The OSS Access Key Id you provided does not exist in our records.解决方法

vue项目

1、安装OSS的Node SDK

npm install ali-oss --save

2、参考官方提示
https://help.aliyun.com/document_detail/111265.html?spm=a2c4g.11186623.6.1198.1ce61b92Dmvktj

复制代码
let client = new OSS({
region: 'oss-cn-beijing',//你的存储空间所在的地点,在OSS后台可以查到。
accessKeyId: res.data.accessKeyId,//accessKeyId,从后台返回
accessKeySecret: res.data.accessKeySecret,//accessKeyId,从后台返回
bucket: '你的bucket名字',//bucket 可以简单理解为存储空间
});
复制代码
结果报错:
The OSS Access Key Id you provided does not exist in our records.
 
解决方法:
添加一行stsToken
复制代码
let client = new OSS({
region: 'oss-cn-beijing',//你的存储空间所在的地点,在OSS后台可以查到。
accessKeyId: res.data.accessKeyId,//accessKeyId,从后台返回
accessKeySecret: res.data.accessKeySecret,//accessKeyId,从后台返回
bucket: '你的bucket名字',//bucket 可以简单理解为存储空间
stsToken: res.data.securityToken//加上这一行,问题解决。
});
复制代码
原文地址:https://www.cnblogs.com/LChenglong/p/11231377.html