Browse Source

修复下载功能

main
zhouxin 4 years ago
parent
commit
50f71bd7c8
  1. 2
      src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java
  2. 22
      src/main/java/com/github/zxbu/webdavteambition/model/DownloadRequest.java
  3. 9
      src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java

2
src/main/java/com/github/zxbu/webdavteambition/client/AliYunDriverClient.java

@ -86,7 +86,7 @@ public class AliYunDriverClient { @@ -86,7 +86,7 @@ public class AliYunDriverClient {
public InputStream download(String url) {
Request request = new Request.Builder().url(url).build();
Request request = new Request.Builder().header("referer", "https://www.aliyundrive.com/").url(url).build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();

22
src/main/java/com/github/zxbu/webdavteambition/model/DownloadRequest.java

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
package com.github.zxbu.webdavteambition.model;
public class DownloadRequest {
private String drive_id;
private String file_id;
public String getDrive_id() {
return drive_id;
}
public void setDrive_id(String drive_id) {
this.drive_id = drive_id;
}
public String getFile_id() {
return file_id;
}
public void setFile_id(String file_id) {
this.file_id = file_id;
}
}

9
src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java

@ -249,8 +249,13 @@ public class AliYunDriverClientService { @@ -249,8 +249,13 @@ public class AliYunDriverClientService {
}
public InputStream download(String path) {
// String downloadUrl = getTFileByPath(path).getDownloadUrl();
return client.download("downloadUrl");
TFile file = getTFileByPath(path);
DownloadRequest downloadRequest = new DownloadRequest();
downloadRequest.setDrive_id(client.getDriveId());
downloadRequest.setFile_id(file.getFile_id());
String json = client.post("/file/get_download_url", downloadRequest);
Object url = JsonUtil.getJsonNodeValue(json, "url");
return client.download(url.toString());
}
private TFile getNodeIdByPath2(String path) {

Loading…
Cancel
Save