|
|
@@ -11,7 +11,7 @@ package io.renren.modules.oss.cloud;
|
|
|
import com.aliyun.oss.ClientConfiguration;
|
|
|
import com.aliyun.oss.OSSClient;
|
|
|
import com.aliyun.oss.common.comm.Protocol;
|
|
|
-import com.aliyun.oss.model.CannedAccessControlList;
|
|
|
+import io.renren.common.constant.Constants;
|
|
|
import io.renren.common.exception.RRException;
|
|
|
import io.renren.common.utils.Constant;
|
|
|
|
|
|
@@ -57,7 +57,7 @@ public class AliyunCloudStorageService extends CloudStorageService {
|
|
|
if(config.getType() == Constant.CloudService.QINIU.getValue()){
|
|
|
return config.getAliyunDomain() + "/" + path;
|
|
|
}else if(config.getType() == Constant.CloudService.ALIYUN.getValue()){
|
|
|
- return getAliyunFileUrl(path);
|
|
|
+ return Constants.HTTPS + config.getAliyunDomain() + "/" + path;
|
|
|
}else if(config.getType() == Constant.CloudService.QCLOUD.getValue()){
|
|
|
return config.getAliyunDomain() + "/" + path;
|
|
|
}else {
|
|
|
@@ -81,10 +81,8 @@ public class AliyunCloudStorageService extends CloudStorageService {
|
|
|
* @return
|
|
|
*/
|
|
|
private String getAliyunFileUrl(String objectName){
|
|
|
- client.setObjectAcl(config.getAliyunBucketName(), objectName, CannedAccessControlList.PublicRead);
|
|
|
- return String.format("https://%s.%s/%s",
|
|
|
- config.getAliyunBucketName(),
|
|
|
- config.getAliyunEndPoint(), // 您的endpoint
|
|
|
- objectName);
|
|
|
+ Date expiration = new Date(new Date().getTime() + 3600l * 1000 * 24 * 365 * 10);
|
|
|
+ String url = client.generatePresignedUrl(config.getAliyunBucketName(), objectName, expiration).toString();
|
|
|
+ return url;
|
|
|
}
|
|
|
}
|