OneDrive 基础路径支持

This commit is contained in:
zhaojun1998
2020-01-31 11:21:36 +08:00
parent f7bb147b71
commit f5724dc9ab
7 changed files with 30 additions and 21 deletions

View File

@@ -83,7 +83,10 @@ public abstract class AbstractOneDriveService {
return oneDriveRestTemplate.getForObject(DRIVER_INFO_URL, String.class);
}
public List<FileItemDTO> list(String path) {
public List<FileItemDTO> list(String basePath, String path) {
path = StringUtils.removeFirstSeparator(path);
String fullPath = StringUtils.getFullPath(basePath, path);
List<FileItemDTO> result = new ArrayList<>();
String nextLink = null;
@@ -93,14 +96,14 @@ public abstract class AbstractOneDriveService {
if (nextLink != null) {
requestUrl = nextLink;
}else if ("/".equalsIgnoreCase(path)) {
}else if ("/".equalsIgnoreCase(fullPath) || "".equalsIgnoreCase(fullPath)) {
requestUrl = DRIVER_ROOT_URL;
} else {
requestUrl = DRIVER_ITEMS_URL;
}
path = StringUtils.removeLastSeparator(path);
fullPath = StringUtils.removeLastSeparator(fullPath);
ResponseEntity<String> responseEntity = oneDriveRestTemplate.getForEntity(requestUrl, String.class, getGraphEndPoint(), path);
ResponseEntity<String> responseEntity = oneDriveRestTemplate.getForEntity(requestUrl, String.class, getGraphEndPoint(), fullPath);
String body = responseEntity.getBody();
JSONObject root = JSON.parseObject(body);