|
@@ -346,6 +346,34 @@ public class OSSLogicImpl implements OSSLogic {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public boolean deleteByUrl(String bucketName, String ossFileNameWithPath) {
|
|
|
+ try{
|
|
|
+ ossClient.deleteObject(bucketName, ossFileNameWithPath);
|
|
|
+ return true;
|
|
|
+ } catch (Exception e){
|
|
|
+ log.error("删除OSS存储对象出错", e);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String copyFileInOss(String bucketName, String sourceFileNameWithPath, String targetFileNameWithPath) {
|
|
|
+ ossClient.copyObject(bucketName, sourceFileNameWithPath, bucketName, targetFileNameWithPath);
|
|
|
+ StringBuilder sb = new StringBuilder("http://");
|
|
|
+ String nohttpEndPoint = endPoint.replace("http://","");
|
|
|
+ sb.append(bucketName).append(".").append(nohttpEndPoint).append("/").append(targetFileNameWithPath);
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String moveFileInOss(String bucketName, String sourceFileNameWithPath, String targetFileNameWithPath) {
|
|
|
+ String targetUrl = this.copyFileInOss(bucketName, sourceFileNameWithPath, targetFileNameWithPath);
|
|
|
+ this.deleteByUrl(bucketName, sourceFileNameWithPath);
|
|
|
+ return targetUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<String> listObjectsByPrefix(String prefix) {
|
|
|
ObjectListing objectListing = ossClient.listObjects(bucketName,prefix);
|
|
|
List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
|