Search in sources :

Example 1 with BatchStatus

use of com.qiniu.storage.model.BatchStatus in project paascloud-master by paascloud.

the class OptQiniuOssServiceImpl method batchDeleteFile.

@Override
public Set<String> batchDeleteFile(String[] fileNameList, String bucketName) throws QiniuException {
    log.info("batchDeleteFile - 删除OSS文件. fileNameList={}, bucketName={}", fileNameList, bucketName);
    BucketManager.BatchOperations batchOperations = new BucketManager.BatchOperations();
    batchOperations.addDeleteOp(bucketName, fileNameList);
    Response response = bucketManager.batch(batchOperations);
    BatchStatus[] batchStatusList = response.jsonToObject(BatchStatus[].class);
    Set<String> failSet = Sets.newHashSet();
    for (int i = 0; i < fileNameList.length; i++) {
        BatchStatus status = batchStatusList[i];
        String fileName = fileNameList[i];
        if (status.code != 200) {
            failSet.add(fileName);
            log.error("batchDeleteFile - 删除OSS文件. [FAIL] fileName={}, error={}", fileName, status.data.error);
        } else {
            log.info("batchDeleteFile - 删除OSS文件. [OK] fileName={}, bucketName={}", fileName, bucketName);
        }
    }
    return failSet;
}
Also used : Response(com.qiniu.http.Response) BucketManager(com.qiniu.storage.BucketManager) BatchStatus(com.qiniu.storage.model.BatchStatus)

Aggregations

Response (com.qiniu.http.Response)1 BucketManager (com.qiniu.storage.BucketManager)1 BatchStatus (com.qiniu.storage.model.BatchStatus)1