创建类 QiniuUtil.java
private static final String ACCESSKEY = ""; private static final String SECRETKEY = ""; // 空间名 private static final String BUCKEY = ""; // 是否可以断点续传(true:可以;false:不可以) private static boolean breakingPoint = false;
上传过程:
1、获取 UploadManager
2、调用 UploadManager.put() 方法上传
3、解析上传结果
创建获取 UploadManager 的方法:
/** * 获取上传类 * @return 上传类 */ private static UploadManager getUploadManager() { FileRecorder fileRecorder = null; if(breakingPoint) { try { fileRecorder = new FileRecorder(Paths.get(System.getenv("java.io.tmpdir"), BUCKEY).toString()); } catch (IOException e) { e.printStackTrace(); } }