阿里云OSS(bucket私有权限)和防盗链之URL签名标签的实现
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">为了减轻服务器的压力,<span style="color: black;">机构</span>可<span style="color: black;">运用</span>阿里云的oss服务器来存放<span style="color: black;">照片</span>。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">1.直接把<span style="color: black;">照片</span>上传到阿里云的oss存储空间(权限设为私有),后端和前端约定<span style="color: black;">照片</span>的路径,后端拼接<span style="color: black;">照片</span>的url存放在数据库,前端从后台调来的url<span style="color: black;">不可</span>直接<span style="color: black;">拜访</span>oss,要再<span style="color: black;">经过</span>签名算法,给url加上签名标签才<span style="color: black;">能够</span><span style="color: black;">拜访</span>。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">2.直接从数据库拿到的url是<span style="color: black;">不可</span><span style="color: black;">拜访</span>oss的<span style="color: black;">照片</span>的,<span style="color: black;">因为</span>oss是<span style="color: black;">根据</span>点击请求收费的,把oss设置为私有能防止网络黑客攻击而<span style="color: black;">引起</span><span style="color: black;">花费</span><span style="color: black;">增多</span>。<span style="color: black;">经过</span>签名算法给url加上签名标签和<span style="color: black;">拜访</span>时效,给url一个临时授权<span style="color: black;">才可</span><span style="color: black;">拜访</span>到,过了<span style="color: black;">拜访</span>时间这个url又变成无效,即防盗链。</span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/954b6729b75d474e8a97f830bcd07f21~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1729509584&x-signature=%2FugrsXTbUJ3UvChnOArGfOQP8%2FU%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.<span style="color: black;">oss设置为私密的链接和<span style="color: black;">咱们</span><span style="color: black;">经过</span>签名算法得到的链接</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">有三个参数OSSAccessKeyId(即AccessKeyId)、Expires(链接失效时间)、Signature(签名算法<span style="color: black;">得到</span>的签名)</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4.设私有</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/1b43c62f050445f1bffdfa0613fb29b1~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1729509584&x-signature=490QumELw4FFGGUO8x0fmPMVgtQ%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5.设资源权限</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/b1717bfbc6404740965a787f778a167d~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1729509584&x-signature=0XzoM45pBiMdNVxCsvrJVvBYMrw%3D" style="width: 50%; margin-bottom: 20px;"></div>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/pgc-image/cf956b36890643d19c98f8af7d7d1692~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1729509584&x-signature=RjcjUjjC3SEcAUiuMX6oNsqAJrE%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">6,设角色</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/72f87df4920246178653a48fa7ff5fb0~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1729509584&x-signature=dZwg%2FDkszGz%2FkhapLrPrQMLYoIU%3D" style="width: 50%; margin-bottom: 20px;"></div>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/5206c312c17746029efd2228051d3949~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1729509584&x-signature=Kl892t1Es1wiE%2BKKXXzZ%2BvuXtw0%3D" style="width: 50%; margin-bottom: 20px;"></div><strong style="color: blue;"><span style="color: black;">阿里云账号</span></strong><span style="color: black;">:<span style="color: black;">准许</span>RAM用户所<span style="color: black;">装扮</span>的角色。<span style="color: black;">装扮</span>角色的RAM用户<span style="color: black;">能够</span>属于自己的阿里云账号,<span style="color: black;">亦</span><span style="color: black;">能够</span>属于其他阿里云账号。此类角色<span style="color: black;">重点</span>用来<span style="color: black;">处理</span>跨账号<span style="color: black;">拜访</span>和临时授权问题。</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"> Bucket 添加标签,<span style="color: black;">每一个</span> Bucket 最多可添加 20 个标签</span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/0374b53bb7344858b9c501616f609ba3~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1729509584&x-signature=equURaWosBSDhJAMtHWskNeWUJY%3D" style="width: 50%; margin-bottom: 20px;"></div>
外链发布社区 http://www.fok120.com/
页:
[1]