com.aliyun.oss.model.DeleteObjectsRequest Java Examples
The following examples show how to use
com.aliyun.oss.model.DeleteObjectsRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AliOssFileHandler.java From halo with GNU General Public License v3.0 | 6 votes |
@Override public void delete(String key) { Assert.notNull(key, "File key must not be blank"); // Get config String endPoint = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ENDPOINT).toString(); String accessKey = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ACCESS_KEY).toString(); String accessSecret = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ACCESS_SECRET).toString(); String bucketName = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_BUCKET_NAME).toString(); // Init OSS client OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, accessSecret); try { ossClient.deleteObject(new DeleteObjectsRequest(bucketName).withKey(key)); } catch (Exception e) { throw new FileOperationException("附件 " + key + " 从阿里云删除失败", e); } finally { ossClient.shutdown(); } }
Example #2
Source File: OSSNotebookRepo.java From zeppelin with Apache License 2.0 | 6 votes |
@Override public void remove(String folderPath, AuthenticationInfo subject) { String nextMarker = null; ObjectListing objectListing = null; do { ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName) .withPrefix(rootFolder + folderPath + "/") .withMarker(nextMarker); objectListing = ossClient.listObjects(listObjectsRequest); if (objectListing.getObjectSummaries().size() > 0) { List<String> keys = new ArrayList(); for (OSSObjectSummary s : objectListing.getObjectSummaries()) { keys.add(s.getKey()); } DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucketName).withKeys(keys); ossClient.deleteObjects(deleteObjectsRequest); } nextMarker = objectListing.getNextMarker(); } while (objectListing.isTruncated()); }
Example #3
Source File: SimpleOssUpload.java From tools with MIT License | 5 votes |
@Override public List<String> deleteFiles(List<String> fileNames, String bucket) { this.createBucket(bucket); if (fileNames.size() > 1000) { throw new IllegalArgumentException("No more than 1000 files are deleted at the same time"); } return this.ossClient.deleteObjects(new DeleteObjectsRequest(bucket).withKeys(fileNames)).getDeletedObjects(); }