From 4e6d717107232de3239c796aa8a8d0650d28426b Mon Sep 17 00:00:00 2001 From: zhouxin Date: Sat, 22 May 2021 20:48:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=97=E8=A1=A8=E3=80=81?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E3=80=81=E5=88=A0=E9=99=A4=E3=80=81=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/AliYunDriverClient.java | 2 +- .../model/CreateFileRequest.java | 57 ++----- .../webdavteambition/model/MoveRequest.java | 48 ++---- .../webdavteambition/model/RemoveRequest.java | 20 +-- .../webdavteambition/model/RenameRequest.java | 30 ++-- .../model/UploadFinalRequest.java | 48 ++---- .../model/UploadPreRequest.java | 125 +++++++++++--- .../webdavteambition/model/result/TFile.java | 9 + .../model/result/UploadPreResult.java | 71 ++++---- .../store/AliYunDriverClientService.java | 156 ++++++++---------- 10 files changed, 294 insertions(+), 272 deletions(-) diff --git a/src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java b/src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java index 3a8b129..642f207 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java +++ b/src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java @@ -63,7 +63,7 @@ public class AliYunDriverClient { .put(RequestBody.create(MediaType.parse(""), bytes, offset, byteCount)) .url(url).build(); try (Response response = okHttpClient.newCall(request).execute()){ - LOGGER.info("post {}, code {}", url, response.code()); + LOGGER.info("upload {}, code {}", url, response.code()); if (!response.isSuccessful()) { LOGGER.error("请求失败,url={}, code={}, body={}", url, response.code(), response.body().string()); throw new WebdavException("请求失败:" + url); diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/CreateFileRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/CreateFileRequest.java index e5393a7..430d898 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/CreateFileRequest.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/CreateFileRequest.java @@ -1,29 +1,26 @@ package com.github.zxbu.webdavteambition.model; public class CreateFileRequest { - private String ccpParentId; - private String checkNameMode = "refuse"; - private String driveId; + private String check_name_mode = "refuse"; + private String drive_id; private String name; - private String orgId; - private String parentId; - private String spaceId; + private String parent_file_id; private String type; - public String getCheckNameMode() { - return checkNameMode; + public String getCheck_name_mode() { + return check_name_mode; } - public void setCheckNameMode(String checkNameMode) { - this.checkNameMode = checkNameMode; + public void setCheck_name_mode(String check_name_mode) { + this.check_name_mode = check_name_mode; } - public String getDriveId() { - return driveId; + public String getDrive_id() { + return drive_id; } - public void setDriveId(String driveId) { - this.driveId = driveId; + public void setDrive_id(String drive_id) { + this.drive_id = drive_id; } public String getName() { @@ -34,28 +31,12 @@ public class CreateFileRequest { this.name = name; } - public String getOrgId() { - return orgId; + public String getParent_file_id() { + return parent_file_id; } - public void setOrgId(String orgId) { - this.orgId = orgId; - } - - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - public String getSpaceId() { - return spaceId; - } - - public void setSpaceId(String spaceId) { - this.spaceId = spaceId; + public void setParent_file_id(String parent_file_id) { + this.parent_file_id = parent_file_id; } public String getType() { @@ -65,12 +46,4 @@ public class CreateFileRequest { public void setType(String type) { this.type = type; } - - public String getCcpParentId() { - return ccpParentId; - } - - public void setCcpParentId(String ccpParentId) { - this.ccpParentId = ccpParentId; - } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/MoveRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/MoveRequest.java index 94a03d5..62182aa 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/MoveRequest.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/MoveRequest.java @@ -3,49 +3,31 @@ package com.github.zxbu.webdavteambition.model; import java.util.List; public class MoveRequest { - private String driveId; - private String parentId; - private String orgId; - private boolean sameLevel = false; - private List ids; - - public String getDriveId() { - return driveId; - } - - public void setDriveId(String driveId) { - this.driveId = driveId; - } - - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } + private String drive_id; + private String file_id; + private String to_parent_file_id; - public String getOrgId() { - return orgId; + public String getDrive_id() { + return drive_id; } - public void setOrgId(String orgId) { - this.orgId = orgId; + public void setDrive_id(String drive_id) { + this.drive_id = drive_id; } - public boolean isSameLevel() { - return sameLevel; + public String getFile_id() { + return file_id; } - public void setSameLevel(boolean sameLevel) { - this.sameLevel = sameLevel; + public void setFile_id(String file_id) { + this.file_id = file_id; } - public List getIds() { - return ids; + public String getTo_parent_file_id() { + return to_parent_file_id; } - public void setIds(List ids) { - this.ids = ids; + public void setTo_parent_file_id(String to_parent_file_id) { + this.to_parent_file_id = to_parent_file_id; } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/RemoveRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/RemoveRequest.java index b1b2e9c..4cf7785 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/RemoveRequest.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/RemoveRequest.java @@ -3,22 +3,22 @@ package com.github.zxbu.webdavteambition.model; import java.util.List; public class RemoveRequest { - private String orgId; - private List nodeIds; + private String drive_id; + private String file_id; - public List getNodeIds() { - return nodeIds; + public String getDrive_id() { + return drive_id; } - public void setNodeIds(List nodeIds) { - this.nodeIds = nodeIds; + public void setDrive_id(String drive_id) { + this.drive_id = drive_id; } - public String getOrgId() { - return orgId; + public String getFile_id() { + return file_id; } - public void setOrgId(String orgId) { - this.orgId = orgId; + public void setFile_id(String file_id) { + this.file_id = file_id; } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/RenameRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/RenameRequest.java index af4316d..7535f22 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/RenameRequest.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/RenameRequest.java @@ -1,25 +1,25 @@ package com.github.zxbu.webdavteambition.model; public class RenameRequest { - private String ccpFileId; - private String driveId; + private String check_name_mode = "refuse"; + private String drive_id; private String name; - private String orgId; + private String file_id; - public String getCcpFileId() { - return ccpFileId; + public String getCheck_name_mode() { + return check_name_mode; } - public void setCcpFileId(String ccpFileId) { - this.ccpFileId = ccpFileId; + public void setCheck_name_mode(String check_name_mode) { + this.check_name_mode = check_name_mode; } - public String getDriveId() { - return driveId; + public String getDrive_id() { + return drive_id; } - public void setDriveId(String driveId) { - this.driveId = driveId; + public void setDrive_id(String drive_id) { + this.drive_id = drive_id; } public String getName() { @@ -30,11 +30,11 @@ public class RenameRequest { this.name = name; } - public String getOrgId() { - return orgId; + public String getFile_id() { + return file_id; } - public void setOrgId(String orgId) { - this.orgId = orgId; + public void setFile_id(String file_id) { + this.file_id = file_id; } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/UploadFinalRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/UploadFinalRequest.java index 9eda77d..8e5064b 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/UploadFinalRequest.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/UploadFinalRequest.java @@ -1,49 +1,31 @@ package com.github.zxbu.webdavteambition.model; public class UploadFinalRequest { - private String ccpFileId; - private String driveId; - private String nodeId; - private String orgId; - private String uploadId; + private String drive_id; + private String file_id; + private String upload_id; - public String getDriveId() { - return driveId; + public String getDrive_id() { + return drive_id; } - public void setDriveId(String driveId) { - this.driveId = driveId; + public void setDrive_id(String drive_id) { + this.drive_id = drive_id; } - public String getNodeId() { - return nodeId; + public String getFile_id() { + return file_id; } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; + public void setFile_id(String file_id) { + this.file_id = file_id; } - public String getOrgId() { - return orgId; + public String getUpload_id() { + return upload_id; } - public void setOrgId(String orgId) { - this.orgId = orgId; - } - - public String getUploadId() { - return uploadId; - } - - public void setUploadId(String uploadId) { - this.uploadId = uploadId; - } - - public String getCcpFileId() { - return ccpFileId; - } - - public void setCcpFileId(String ccpFileId) { - this.ccpFileId = ccpFileId; + public void setUpload_id(String upload_id) { + this.upload_id = upload_id; } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java index d927c87..679ccb6 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java @@ -3,49 +3,124 @@ package com.github.zxbu.webdavteambition.model; import java.util.List; public class UploadPreRequest { - private String checkNameMode = "autoRename"; - private String orgId; - private String parentId; - private String spaceId; - private List infos; + private String check_name_mode = "refuse"; + private String content_hash; + private String content_hash_name = "sha1"; + private String drive_id; + private String name; + private String parent_file_id; + private String proof_code; + private String proof_version = "v1"; + private Long size; + private List part_info_list; + private String type = "file"; - public String getCheckNameMode() { - return checkNameMode; + public String getCheck_name_mode() { + return check_name_mode; } - public void setCheckNameMode(String checkNameMode) { - this.checkNameMode = checkNameMode; + public void setCheck_name_mode(String check_name_mode) { + this.check_name_mode = check_name_mode; } - public String getOrgId() { - return orgId; + public String getContent_hash() { + return content_hash; } - public void setOrgId(String orgId) { - this.orgId = orgId; + public void setContent_hash(String content_hash) { + this.content_hash = content_hash; } - public String getParentId() { - return parentId; + public String getContent_hash_name() { + return content_hash_name; } - public void setParentId(String parentId) { - this.parentId = parentId; + public void setContent_hash_name(String content_hash_name) { + this.content_hash_name = content_hash_name; } - public String getSpaceId() { - return spaceId; + public String getDrive_id() { + return drive_id; } - public void setSpaceId(String spaceId) { - this.spaceId = spaceId; + public void setDrive_id(String drive_id) { + this.drive_id = drive_id; } - public List getInfos() { - return infos; + public String getName() { + return name; } - public void setInfos(List infos) { - this.infos = infos; + public void setName(String name) { + this.name = name; + } + + public String getParent_file_id() { + return parent_file_id; + } + + public void setParent_file_id(String parent_file_id) { + this.parent_file_id = parent_file_id; + } + + public String getProof_code() { + return proof_code; + } + + public void setProof_code(String proof_code) { + this.proof_code = proof_code; + } + + public String getProof_version() { + return proof_version; + } + + public void setProof_version(String proof_version) { + this.proof_version = proof_version; + } + + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } + + public List getPart_info_list() { + return part_info_list; + } + + public void setPart_info_list(List part_info_list) { + this.part_info_list = part_info_list; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class PartInfo { + private Integer part_number; + private String upload_url; + + public Integer getPart_number() { + return part_number; + } + + public void setPart_number(Integer part_number) { + this.part_number = part_number; + } + + public String getUpload_url() { + return upload_url; + } + + public void setUpload_url(String upload_url) { + this.upload_url = upload_url; + } } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/result/TFile.java b/src/main/java/com/github/zxbu/webdavteambition/model/result/TFile.java index 9aa5daa..246bc3a 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/result/TFile.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/result/TFile.java @@ -11,6 +11,7 @@ public class TFile { private String file_id; private Boolean hidden; private String name; + private String file_name; private String parent_file_id; private String starred; private String status; @@ -136,6 +137,14 @@ public class TFile { this.download_url = download_url; } + public String getFile_name() { + return file_name; + } + + public void setFile_name(String file_name) { + this.file_name = file_name; + } + public void setUpdated_at(Date updated_at) { this.updated_at = updated_at; } diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/result/UploadPreResult.java b/src/main/java/com/github/zxbu/webdavteambition/model/result/UploadPreResult.java index d5d1979..957bba9 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/result/UploadPreResult.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/result/UploadPreResult.java @@ -1,60 +1,71 @@ package com.github.zxbu.webdavteambition.model.result; +import com.github.zxbu.webdavteambition.model.UploadPreRequest; + import java.util.List; public class UploadPreResult { - private String ccpFileId; - private String nodeId; - private String name; - private String kind; - private String uploadId; - private List uploadUrl; + private String file_id; + private String file_name; + private String location; + private Boolean rapid_upload; + private String type; + private String upload_id; + private List part_info_list; + + public String getFile_id() { + return file_id; + } + + public void setFile_id(String file_id) { + this.file_id = file_id; + } - public String getNodeId() { - return nodeId; + public String getFile_name() { + return file_name; } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; + public void setFile_name(String file_name) { + this.file_name = file_name; } - public String getName() { - return name; + public String getLocation() { + return location; } - public void setName(String name) { - this.name = name; + public void setLocation(String location) { + this.location = location; } - public String getCcpFileId() { - return ccpFileId; + public Boolean getRapid_upload() { + return rapid_upload; } - public void setCcpFileId(String ccpFileId) { - this.ccpFileId = ccpFileId; + public void setRapid_upload(Boolean rapid_upload) { + this.rapid_upload = rapid_upload; } - public String getKind() { - return kind; + public String getType() { + return type; } - public void setKind(String kind) { - this.kind = kind; + public void setType(String type) { + this.type = type; } - public String getUploadId() { - return uploadId; + public String getUpload_id() { + return upload_id; } - public void setUploadId(String uploadId) { - this.uploadId = uploadId; + public void setUpload_id(String upload_id) { + this.upload_id = upload_id; } - public List getUploadUrl() { - return uploadUrl; + public List getPart_info_list() { + return part_info_list; } - public void setUploadUrl(List uploadUrl) { - this.uploadUrl = uploadUrl; + public void setPart_info_list(List part_info_list) { + this.part_info_list = part_info_list; } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java index 4281908..523aa86 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java +++ b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java @@ -96,71 +96,72 @@ public class AliYunDriverClientService { int chunkCount = (int) Math.ceil(((double) size) / chunkSize); // 进1法 UploadPreRequest uploadPreRequest = new UploadPreRequest(); -// uploadPreRequest.setOrgId(client.getOrgId()); -// uploadPreRequest.setParentId(parent.getNodeId()); -// uploadPreRequest.setSpaceId(client.getSpaceId()); - UploadPreInfo uploadPreInfo = new UploadPreInfo(); -// uploadPreInfo.setCcpParentId(parent.getCcpFileId()); - uploadPreInfo.setDriveId(client.getDriveId()); - uploadPreInfo.setName(pathInfo.getName()); - uploadPreInfo.setSize(size); - uploadPreInfo.setChunkCount(chunkCount); - uploadPreInfo.setType(FileType.file.name()); - uploadPreRequest.setInfos(Collections.singletonList(uploadPreInfo)); + uploadPreRequest.setContent_hash(UUID.randomUUID().toString()); + uploadPreRequest.setDrive_id(client.getDriveId()); + uploadPreRequest.setName(pathInfo.getName()); + uploadPreRequest.setParent_file_id(parent.getFile_id()); + uploadPreRequest.setSize((long) size); + List part_info_list = new ArrayList<>(); + for (int i = 0; i < chunkCount; i++) { + UploadPreRequest.PartInfo partInfo = new UploadPreRequest.PartInfo(); + partInfo.setPart_number(i + 1); + part_info_list.add(partInfo); + } + uploadPreRequest.setPart_info_list(part_info_list); + LOGGER.info("开始上传文件,文件名:{},总大小:{}, 文件块数量:{}", path, size, chunkCount); - String json = client.post("/pan/api/nodes/file", uploadPreRequest); - List uploadPreResultList = JsonUtil.readValue(json, new TypeReference>() { - }); - UploadPreResult uploadPreResult = uploadPreResultList.get(0); - List uploadUrl = uploadPreResult.getUploadUrl(); - LOGGER.info("文件预处理成功,开始上传。文件名:{},上传URL数量:{}", path, uploadUrl.size()); - - byte[] buffer = new byte[chunkSize]; - for (int i = 0; i < uploadUrl.size(); i++) { - String oneUploadUrl = uploadUrl.get(i); - try { - int read = IOUtils.read(inputStream, buffer, 0, buffer.length); - if (read == -1) { - return; - } - client.upload(oneUploadUrl, buffer, 0, read); - LOGGER.info("文件正在上传。文件名:{},当前进度:{}/{}", path, (i+1), uploadUrl.size()); + String json = client.post("/file/create_with_proof", uploadPreRequest); + UploadPreResult uploadPreResult = JsonUtil.readValue(json, UploadPreResult.class); + List partInfoList = uploadPreResult.getPart_info_list(); + if (partInfoList != null) { + LOGGER.info("文件预处理成功,开始上传。文件名:{},上传URL数量:{}", path, partInfoList.size()); - } catch (IOException e) { - throw new WebdavException(e); + byte[] buffer = new byte[chunkSize]; + for (int i = 0; i < partInfoList.size(); i++) { + UploadPreRequest.PartInfo partInfo = partInfoList.get(i); + try { + int read = IOUtils.read(inputStream, buffer, 0, buffer.length); + if (read == -1) { + return; + } + client.upload(partInfo.getUpload_url(), buffer, 0, read); + LOGGER.info("文件正在上传。文件名:{},当前进度:{}/{}", path, (i+1), partInfoList.size()); + + } catch (IOException e) { + throw new WebdavException(e); + } } } + UploadFinalRequest uploadFinalRequest = new UploadFinalRequest(); - uploadFinalRequest.setCcpFileId(uploadPreResult.getCcpFileId()); - uploadFinalRequest.setDriveId(client.getDriveId()); - uploadFinalRequest.setNodeId(uploadPreResult.getNodeId()); -// uploadFinalRequest.setOrgId(client.getOrgId()); - uploadFinalRequest.setUploadId(uploadPreResult.getUploadId()); - client.post("/pan/api/nodes/complete", uploadFinalRequest); + uploadFinalRequest.setFile_id(uploadPreResult.getFile_id()); + uploadFinalRequest.setDrive_id(client.getDriveId()); + uploadFinalRequest.setUpload_id(uploadPreResult.getUpload_id()); + + client.post("/file/complete", uploadFinalRequest); LOGGER.info("文件上传成功。文件名:{}", path); - if (!uploadPreResult.getName().equals(pathInfo.getName())) { - LOGGER.info("上传文件名{}与原文件名{}不同,对文件进行重命名", uploadPreResult.getName(), pathInfo.getName()); - TFile oldFile = getNodeIdByPath2(path); - // 如果旧文件存在,则先删除 - if (oldFile != null) { - LOGGER.info("旧文件{}还存在,大小为{},进行删除操作,可前往网页版的回收站查看", path, oldFile.getSize()); - remove(path); - try { - Thread.sleep(1500); - } catch (InterruptedException e) { - // no - } - } - RenameRequest renameRequest = new RenameRequest(); - renameRequest.setCcpFileId(uploadPreResult.getCcpFileId()); - renameRequest.setDriveId(client.getDriveId()); -// renameRequest.setOrgId(client.getOrgId()); - renameRequest.setName(pathInfo.getName()); - client.put("/pan/api/nodes/" + uploadPreResult.getNodeId(), renameRequest); - } +// if (!uploadPreResult.getName().equals(pathInfo.getName())) { +// LOGGER.info("上传文件名{}与原文件名{}不同,对文件进行重命名", uploadPreResult.getName(), pathInfo.getName()); +// TFile oldFile = getNodeIdByPath2(path); +// // 如果旧文件存在,则先删除 +// if (oldFile != null) { +// LOGGER.info("旧文件{}还存在,大小为{},进行删除操作,可前往网页版的回收站查看", path, oldFile.getSize()); +// remove(path); +// try { +// Thread.sleep(1500); +// } catch (InterruptedException e) { +// // no +// } +// } +// RenameRequest renameRequest = new RenameRequest(); +// renameRequest.setDrive_id(client.getDriveId()); +// renameRequest.setFile_id(oldFile.getFile_id()); +// renameRequest.setName(pathInfo.getName()); +// client.post("/file/update", renameRequest); +// } clearCache(); } @@ -168,11 +169,10 @@ public class AliYunDriverClientService { sourcePath = normalizingPath(sourcePath); TFile tFile = getTFileByPath(sourcePath); RenameRequest renameRequest = new RenameRequest(); -// renameRequest.setCcpFileId(tFile.getCcpFileId()); - renameRequest.setDriveId(client.getDriveId()); -// renameRequest.setOrgId(client.getOrgId()); + renameRequest.setDrive_id(client.getDriveId()); + renameRequest.setFile_id(tFile.getFile_id()); renameRequest.setName(newName); -// client.put("/pan/api/nodes/" + tFile.getNodeId(), renameRequest); + client.post("/file/update", renameRequest); clearCache(); } @@ -183,15 +183,10 @@ public class AliYunDriverClientService { TFile sourceTFile = getTFileByPath(sourcePath); TFile targetTFile = getTFileByPath(targetPath); MoveRequest moveRequest = new MoveRequest(); -// moveRequest.setOrgId(client.getOrgId()); - moveRequest.setDriveId(client.getDriveId()); -// moveRequest.setParentId(targetTFile.getNodeId()); - MoveRequestId moveRequestId = new MoveRequestId(); -// moveRequestId.setCcpFileId(sourceTFile.getCcpFileId()); -// moveRequestId.setId(sourceTFile.getNodeId()); - moveRequest.setIds(Collections.singletonList(moveRequestId)); - client.post("/pan/api/nodes/move", moveRequest); - clearCache(); + moveRequest.setDrive_id(client.getDriveId()); + moveRequest.setFile_id(sourceTFile.getFile_id()); + moveRequest.setTo_parent_file_id(targetTFile.getFile_id()); + client.post("/file/move", moveRequest); clearCache(); } @@ -202,9 +197,9 @@ public class AliYunDriverClientService { return; } RemoveRequest removeRequest = new RemoveRequest(); -// removeRequest.setOrgId(client.getOrgId()); -// removeRequest.setNodeIds(Collections.singletonList(tFile.getNodeId())); - client.post("/pan/api/nodes/archive", removeRequest); + removeRequest.setDrive_id(client.getDriveId()); + removeRequest.setFile_id(tFile.getFile_id()); + client.post("/recyclebin/trash", removeRequest); clearCache(); } @@ -219,21 +214,16 @@ public class AliYunDriverClientService { } CreateFileRequest createFileRequest = new CreateFileRequest(); -// createFileRequest.setCcpParentId(parent.getCcpFileId()); - createFileRequest.setDriveId(client.getDriveId()); + createFileRequest.setDrive_id(client.getDriveId()); createFileRequest.setName(pathInfo.getName()); -// createFileRequest.setOrgId(client.getOrgId()); -// createFileRequest.setParentId(parent.getNodeId()); -// createFileRequest.setSpaceId(client.getSpaceId()); + createFileRequest.setParent_file_id(parent.getFile_id()); createFileRequest.setType(FileType.folder.name()); - String json = client.post("/pan/api/nodes/folder", createFileRequest); - List createFileResults = JsonUtil.readValue(json, new TypeReference>() { - }); - if (createFileResults.size() != 1) { + String json = client.post("/file/create_with_proof", createFileRequest); + TFile createFileResult = JsonUtil.readValue(json, TFile.class); + if (createFileResult.getFile_name() == null) { LOGGER.error("创建目录{}失败: {}",path, json); } - CreateFileResult createFileResult = createFileResults.get(0); - if (!createFileResult.getName().equals(pathInfo.getName())) { + if (!createFileResult.getFile_name().equals(pathInfo.getName())) { LOGGER.info("创建目录{}与原值{}不同,重命名", createFileResult.getName(), pathInfo.getName()); rename(pathInfo.getParentPath() + "/" + createFileResult.getName(), pathInfo.getName()); clearCache();