这个问题出现的原因是阿里云升级了OSS。
https://help.aliyun.com/noticelist/articleid/1060057906.html
具体的原因是:Response Header中会自动加上 Content-Disposition:'attachment=filename;'。即从浏览器访问图片类型文件时,会以附件形式进行下载。
用户使用自有域名访问OSS的请求,Response Header中不会加上此信息。
去提交了工单,客服回复要绑定域名才行。但是域名比较麻烦,我在网上找了半天。发现可以设置请求头的方式。
我这里上传图片的SDK是用 Node.js
1.上传时加上请求头
let uploadimg = function(image){
return new Promise((resolve,reject)=>{
client.put('dingdan/' + image,image,{
// 一定要加上请求头
headers: {
'Content-Type': 'image/jpg'
}
})
.then((res)=>{
resolve(res.url)
})
.catch((err)=>{
reject(err)
})
})
}
2.取消https
点击详情
取消https