西安做网站价格,wordpress仿京东,net网站开发找那家,wordpress时间不对如果OSS文件设置保护#xff0c;需要鉴权才能访问#xff0c;添加请求头鉴权#xff0c;SDK方法如上#xff1b;
将鉴权信息和地址、时间返回给前端#xff0c;前端直接从oss上读取
String filePath /admin/2023/6/183569314928918546.png;
RequestMessage… 如果OSS文件设置保护需要鉴权才能访问添加请求头鉴权SDK方法如上
将鉴权信息和地址、时间返回给前端前端直接从oss上读取
String filePath /admin/2023/6/183569314928918546.png;
RequestMessage requestMessage new RequestMessage(sl-ops-oss, filePath);
SimpleDateFormat sdf new SimpleDateFormat(EEE, d MMM yyyy HH:mm:ss GMT, Locale.US);
Calendar cd Calendar.getInstance();
sdf.setTimeZone(TimeZone.getTimeZone(GMT)); // 设置时区为GMT
String str sdf.format(cd.getTime());
System.out.println(str);
MapString, String headers new HashMap();
headers.put(Date, str);
requestMessage.setHeaders(headers);
String signature SignUtils.buildSignature(ossSecretAccessKey, GET, / bucket / filePath, requestMessage);
String Authorization SignUtils.composeRequestAuthorization(ossAccessKeyId, signature);
JSONObject jsonObject new JSONObject();
jsonObject.put(Date, str);
jsonObject.put(Authorization, Authorization);
jsonObject.put(url, String.format(url, bucket) filePath);