diff --git a/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/ClusterFileManager.java b/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/ClusterFileManager.java index 4e3e48b6f..1de2394f4 100644 --- a/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/ClusterFileManager.java +++ b/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/ClusterFileManager.java @@ -1,5 +1,6 @@ package org.jetlinks.community.io.file; +import com.alibaba.excel.util.StringUtils; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.ByteBufUtil; @@ -24,6 +25,7 @@ import org.springframework.http.codec.multipart.FilePart; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; import java.io.File; import java.nio.file.NoSuchFileException; @@ -168,6 +170,9 @@ public Mono saveFile(String name, Flux stream, FileOption. @Override public Mono saveFile(String name, String folder, Flux stream, FileOption... options) { + if (folder.contains("/")) { + return Mono.error(new BusinessException("error.folder_cannot_contains:/")); + } return doSaveFile(name, folder, stream, options); } @@ -277,6 +282,7 @@ public void handleDeleteEvent(EntityDeletedEvent event) { .map(entity -> Paths.get(properties.getStorageBasePath(), entity.getStoragePath()).toFile()) .filter(File::exists) .map(File::delete) + .subscribeOn(Schedulers.boundedElastic()) ); } diff --git a/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/web/FileManagerController.java b/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/web/FileManagerController.java index b4e7bd892..fbe96977c 100644 --- a/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/web/FileManagerController.java +++ b/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/web/FileManagerController.java @@ -81,7 +81,7 @@ public Mono read(@PathVariable String fileId, .getHeaders() .getRange(); long position = 0; - if (ranges.size() != 0) { + if (!ranges.isEmpty()) { position = ranges.get(0).getRangeStart(ctx.info().getLength()); } ctx.position(position);