Skip to content

Commit

Permalink
支持 自动将下载完成的文件上传至alist
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuo894 committed Nov 13, 2024
1 parent 3eaa5a6 commit 6e6ae52
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/ani/rss/util/AlistUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ public static void upload(TorrentsInfo torrentsInfo) {
filePath += "/" + string;
String finalFilePath = filePath;
EXECUTOR.execute(() -> {
log.info("上传 {} ==> {}", string, finalFilePath);
File file = new File(downloadDir + "/" + string);
if (!file.exists()) {
log.error("文件不存在 {}", file);
return;
}
log.info("上传 {} ==> {}", file, finalFilePath);
try {
String url = alistHost;
if (url.endsWith("/")) {
Expand All @@ -78,7 +83,7 @@ public static void upload(TorrentsInfo torrentsInfo) {
.header(Header.AUTHORIZATION, alistToken)
.header("As-Task", "true")
.header("File-Path", URLUtil.encode(finalFilePath))
.form("file", new File(downloadDir + "/" + string))
.form("file", file)
.then(res -> {
Assert.isTrue(res.isOk(), "上传失败 {} 状态码:{}", string, res.getStatus());
log.info("已向alist添加上传任务 {}", string);
Expand Down

0 comments on commit 6e6ae52

Please sign in to comment.