public static boolean removePicture(String url, String endpoint, String bucketName, String accessKeyId, String accessKeySecret) throws ClientException {
boolean result = false;
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
try {
String fileName = url.substring(url.lastIndexOf(endpoint) + endpoint.length() + 1);
if (ossClient.doesObjectExist(bucketName, fileName)) {
ossClient.deleteObject(bucketName, fileName);
result = true;
}
} catch (OSSException e) {
return false;
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
return result;
}
如何使用可看这篇文章OSS对象存储使用