Skip to content

Commit

Permalink
处理内存溢出
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuo894 committed Nov 13, 2024
1 parent d2c4ce2 commit f7249da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 0 additions & 2 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
支持 自动将下载完成的文件上传至alist

此功能需要更新docker容器
5 changes: 2 additions & 3 deletions src/main/java/ani/rss/util/AlistUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ani.rss.entity.TorrentsInfo;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.NioUtil;
import cn.hutool.core.io.resource.InputStreamResource;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.thread.ExecutorBuilder;
import cn.hutool.core.util.StrUtil;
Expand Down Expand Up @@ -82,7 +81,7 @@ public static void upload(TorrentsInfo torrentsInfo) {
url = url.substring(0, url.length() - 1);
}
// 使用流式上传
url += "/api/fs/put";
url += "/api/fs/form";

HttpConfig httpConfig = new HttpConfig()
.setBlockSize(NioUtil.DEFAULT_BUFFER_SIZE);
Expand All @@ -95,7 +94,7 @@ public static void upload(TorrentsInfo torrentsInfo) {
.header("As-Task", "true")
.header("File-Path", URLUtil.encode(finalFilePath))
.header(Header.CONTENT_LENGTH, String.valueOf(file.length()))
.body(new InputStreamResource(inputStream))
.form("file", file)
.then(res -> {
Assert.isTrue(res.isOk(), "上传失败 {} 状态码:{}", string, res.getStatus());
log.info("已向alist添加上传任务 {}", string);
Expand Down

0 comments on commit f7249da

Please sign in to comment.