com.upyun.UpException Java Examples
The following examples show how to use
com.upyun.UpException.
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: UpOssFileHandler.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 password = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_PASSWORD).toString(); String bucket = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_BUCKET).toString(); String operator = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_OPERATOR).toString(); RestManager manager = new RestManager(bucket, operator, password); manager.setTimeout(60 * 10); manager.setApiDomain(RestManager.ED_AUTO); try { Response result = manager.deleteFile(key, null); if (!result.isSuccessful()) { log.warn("附件 " + key + " 从又拍云删除失败"); } } catch (IOException | UpException e) { e.printStackTrace(); throw new FileOperationException("附件 " + key + " 从又拍云删除失败", e); } }
Example #2
Source File: UpYunServiceImpl.java From zfile with MIT License | 5 votes |
@Override public FileItemDTO getFileItem(String path) { try { int lastDelimiterIndex = path.lastIndexOf("/"); String name = path.substring(lastDelimiterIndex + 1); Map<String, String> fileInfo = upYun.getFileInfo(StringUtils.removeDuplicateSeparator(basePath + ZFileConstant.PATH_SEPARATOR + path)); if (fileInfo == null) { throw new NotExistFileException(); } FileItemDTO fileItemDTO = new FileItemDTO(); fileItemDTO.setName(name); fileItemDTO.setSize(Long.valueOf(fileInfo.get("size"))); fileItemDTO.setTime(new Date(Long.parseLong(fileInfo.get("date")) * 1000)); fileItemDTO.setPath(path); if ("folder".equals(fileInfo.get("type"))) { fileItemDTO.setType(FileTypeEnum.FOLDER); } else { fileItemDTO.setType(FileTypeEnum.FILE); fileItemDTO.setUrl(getDownloadUrl(StringUtils.removeDuplicateSeparator(basePath + ZFileConstant.PATH_SEPARATOR + path))); } return fileItemDTO; } catch (IOException | UpException e) { e.printStackTrace(); } throw new NotExistFileException(); }
Example #3
Source File: UpYunUploader.java From poster-generater with MIT License | 5 votes |
@Override public UploadResult upload(File file) throws IOException { String filepath = this.upYunConfig.getPrefix() + "/" + DigestUtils.md5DigestAsHex(new FileInputStream(file)); try { boolean flag = this.upyun.writeFile(filepath, file); if (flag) { return new UploadResult(this.upYunConfig.url(filepath)); } throw new IOException("文件上传失败"); } catch (UpException e) { throw new IOException("文件上传失败:" + e.getMessage()); } }