Java Code Examples for com.qiniu.http.Response#jsonToObject()
The following examples show how to use
com.qiniu.http.Response#jsonToObject() .
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: OptQiniuOssServiceImpl.java From paascloud-master with Apache License 2.0 | 6 votes |
@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; }
Example 2
Source File: QiNiuUtil.java From javabase with Apache License 2.0 | 6 votes |
/** * 删除图片 * https://developer.qiniu.com/kodo/sdk/java#rs-batch-delete * 每次只能删除小于1000条数据 * * @param list */ public void deleteByList(List<String> list) { try { if (list == null) return; log.info("待删除图片大小:{}", list.size()); String[] keyList = new String[list.size()]; for (int i = 0; i < list.size(); i++) { keyList[i] = list.get(i).replace(domain, ""); } BucketManager.BatchOperations batchOperations = new BucketManager.BatchOperations(); batchOperations.addDeleteOp(bucketName, keyList); Response response = bucketManager.batch(batchOperations); BatchStatus[] batchStatusList = response.jsonToObject(BatchStatus[].class); /*for (int k = 0; k < keyList.length; k++) { BatchStatus status = batchStatusList[k]; if (status.code == 200) { // log.info("delete success"); } else { log.error("删除失败", status.toString()); } }*/ } catch (QiniuException e) { log.error("七牛上传 response:" + e.getLocalizedMessage()); } }
Example 3
Source File: QiniuService.java From expper with GNU General Public License v3.0 | 6 votes |
public QiniuResult uploadPicture(String login, MultipartFile picture) throws IOException { User user = userRepository.findByLogin(login); String key = pictureKey(user.getId()); String token = authToken(key); File file = convert(picture); Response res = uploadManager.put(file, key, token, null, null, true); QiniuResult result = res.jsonToObject(QiniuResult.class); file.delete(); user.setPicture(key); userRepository.save(user); return result; }
Example 4
Source File: QiniuProvider.java From azeroth with Apache License 2.0 | 5 votes |
/** * 处理上传结果,返回文件url * * @return * @throws QiniuException */ private String processUploadResponse(Response res) throws QiniuException { if (res.isOK()) { UploadResult ret = res.jsonToObject(UploadResult.class); return getFullPath(ret.key); } throw new FSOperErrorException(name(), res.toString()); }
Example 5
Source File: SdkManager.java From qiniu with MIT License | 5 votes |
/** * 批量删除文件,单次批量请求的文件数量不得超过1000 */ public BatchStatus[] batchDelete(String bucket, String[] keys) throws QiniuException { BucketManager.BatchOperations batchOperations = new BucketManager.BatchOperations(); batchOperations.addDeleteOp(bucket, keys); Response response = SdkConfigurer.getBucketManager().batch(batchOperations); return response.jsonToObject(BatchStatus[].class); }
Example 6
Source File: QiniuProvider.java From jeesuite-libs with Apache License 2.0 | 5 votes |
/** * 处理上传结果,返回文件url * * @return * @throws QiniuException */ private String processUploadResponse(Response res) throws QiniuException { if (res.isOK()) { UploadResult ret = res.jsonToObject(UploadResult.class); return getFullPath(ret.key); } throw new FSOperErrorException(name(), res.toString()); }