Browse Source

文件删除

xiatian 5 years ago
parent
commit
7300e92876

+ 6 - 1
src/main/java/cn/com/qmth/examcloud/web/filestorage/FileStorage.java

@@ -20,7 +20,7 @@ public interface FileStorage {
 	
 	/**保存文件到存储服务,siteId为1,转换接口用
 	 * @param file 文件
-	 * @param path 全路径,包含根目录,不含协议名
+	 * @param path 全路径,含协议名
 	 * @return 返回路径
 	 */
 	public YunPathInfo saveFile(File file, String path);
@@ -33,4 +33,9 @@ public interface FileStorage {
 	 */
 	public YunHttpRequest  getSignature(String siteId,FileStoragePathEnvInfo env,String md5);
 	
+	/**删除文件
+	 * @param path 全路径,含协议名
+	 */
+	public void deleteFile(String path) ;
+	
 }

+ 14 - 0
src/main/java/cn/com/qmth/examcloud/web/filestorage/FileStorageUtil.java

@@ -262,4 +262,18 @@ public class FileStorageUtil {
 		// 新协议无需处理
 		return sourcePath;
 	}
+	
+	
+	/**删除云存储文件
+	 * @param path 全路径,包含根目录,含协议名
+	 */
+	public static void deleteFile(String path) {
+		path=diposeOldPath(path);
+		// 如果是全路径直接返回
+		if (path.startsWith("http") || path.startsWith("https")) {
+			return;
+		}
+		FileStorage fs = SpringContextHolder.getBean(getHead(path).toLowerCase() + beanSuff, FileStorage.class);
+		fs.deleteFile(path);
+	}
 }

+ 6 - 0
src/main/java/cn/com/qmth/examcloud/web/filestorage/impl/AliyunFileStorageImpl.java

@@ -283,4 +283,10 @@ public class AliyunFileStorageImpl implements FileStorage {
 		request.setFormUrl(urlStr);
 		return request;
 	}
+
+	@Override
+	public void deleteFile(String path) {
+		// TODO Auto-generated method stub
+		
+	}
 }

+ 6 - 0
src/main/java/cn/com/qmth/examcloud/web/filestorage/impl/UpyunFileStorageImpl.java

@@ -83,4 +83,10 @@ public class UpyunFileStorageImpl implements FileStorage {
 		return ret;
 	}
 
+	@Override
+	public void deleteFile(String path) {
+		// TODO Auto-generated method stub
+		
+	}
+
 }