|
@@ -129,6 +129,23 @@ public class OSSUtil {
|
|
|
return Base64Encoder.encode(data.toByteArray());
|
|
|
}
|
|
|
|
|
|
+ public static boolean deleteFile(OSSConfig ossConfig,String filePath) {
|
|
|
+ OSS ossClient = new OSSClientBuilder().build(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
|
|
|
+
|
|
|
+ boolean exist = ossClient.doesObjectExist(ossConfig.getBucketName(), filePath);
|
|
|
+
|
|
|
+ if (!exist) {
|
|
|
+ log.error("文件不存在,filePath={}", filePath);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("删除文件,filePath={}", filePath);
|
|
|
+ ossClient.deleteObject(ossConfig.getBucketName(), filePath);
|
|
|
+
|
|
|
+ ossClient.shutdown();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
public static void batchDownload(List<Map<String,Object>> fileList, OutputStream output){
|
|
|
try{
|