错误一:
js报错:
aliyun-oss-sdk.min.js:10 OPTIONS http://tyzkj.oss-cn-shenzhen.aliyuncs.com/tyzkj/2019-05-23/20190523100040.mp4?uploads= 403 (Forbidden)
addVideo:1 Access to fetch at 'http://tyzkj.oss-cn-shenzhen.aliyuncs.com/tyzkj/2019-05-23/20190523100040.mp4?uploads=' from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
解决办法:
1.
2.
错误二:
RAM,没有权限的问题
需要配置用户和角色
1.创建用户和创建角色
2.分配权限
错误三:
net::ERR_SSL_PROTOCOL_ERROR
原因: 本地测试是http链接,线上服务器是https链接
解决办法:
1. 修改js
<script th:src="@{http://gosspublic.alicdn.com/aliyun-oss-sdk.min.js}"></script> 为<script th:src="@{https://gosspublic.alicdn.com/aliyun-oss-sdk.min.js}"></script>
2. 或者把js下载下来放到项目中
3.如果还是报错
把 public static String endpointS = "http://oss-cn-shenzhen.aliyuncs.com";修改为
public static String endpointS = "https://oss-cn-shenzhen.aliyuncs.com";
原因:oss默认是走的http请求,在https下http请求就会被拒绝,需要在endpoint字段加入“https://”,改成https连接