diff --git a/pom.xml b/pom.xml
index 8702caf..d25c9b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,6 +30,12 @@
3.14.9
+
+ com.github.ben-manes.caffeine
+ caffeine
+ 2.7.0
+
+
org.springframework.boot
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 31a8918..a57444f 100644
--- a/src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java
+++ b/src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java
@@ -7,6 +7,7 @@ import okhttp3.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
import java.io.IOException;
import java.io.InputStream;
@@ -92,8 +93,12 @@ public class AliYunDriverClient {
}
- public InputStream download(String url) {
- Request request = new Request.Builder().header("referer", "https://www.aliyundrive.com/").url(url).build();
+ public InputStream download(String url, String range) {
+ Request.Builder builder = new Request.Builder().header("referer", "https://www.aliyundrive.com/");
+ if (StringUtils.hasLength(range)) {
+ builder.header("range", range);
+ }
+ Request request = builder.url(url).build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/DownloadRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/DownloadRequest.java
index b3aec42..67c3429 100644
--- a/src/main/java/com/github/zxbu/webdavteambition/model/DownloadRequest.java
+++ b/src/main/java/com/github/zxbu/webdavteambition/model/DownloadRequest.java
@@ -3,6 +3,7 @@ package com.github.zxbu.webdavteambition.model;
public class DownloadRequest {
private String drive_id;
private String file_id;
+ private Integer expire_sec = 14400;
public String getDrive_id() {
return drive_id;
@@ -19,4 +20,12 @@ public class DownloadRequest {
public void setFile_id(String file_id) {
this.file_id = file_id;
}
+
+ public Integer getExpire_sec() {
+ return expire_sec;
+ }
+
+ public void setExpire_sec(Integer expire_sec) {
+ this.expire_sec = expire_sec;
+ }
}
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 ce28b9e..05bfae6 100644
--- a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java
+++ b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java
@@ -2,6 +2,8 @@ package com.github.zxbu.webdavteambition.store;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.zxbu.webdavteambition.client.AliYunDriverClient;
import com.github.zxbu.webdavteambition.model.*;
import com.github.zxbu.webdavteambition.model.result.TFile;
@@ -21,6 +23,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
@Service
public class AliYunDriverClientService {
@@ -29,7 +32,12 @@ public class AliYunDriverClientService {
private static String rootPath = "/";
private static int chunkSize = 10485760; // 10MB
private TFile rootTFile = null;
- private final ThreadLocal