瀏覽代碼

优化文件上传

zhou-hao 5 年之前
父節點
當前提交
8473ca3c7f

+ 2 - 2
hsweb-system/hsweb-system-file/src/main/java/org/hswebframework/web/file/FileUploadProperties.java

@@ -24,13 +24,13 @@ public class FileUploadProperties {
         String filePath = DateFormatter.toString(new Date(), "yyyyMMdd");
         String absPath = staticFilePath.concat("/").concat(filePath);
         //文件后缀
-        String suffix =  name.contains(".") ?
+        String suffix = name.contains(".") ?
                 name.substring(name.lastIndexOf(".")) : "";
 
         new File(absPath).mkdirs();
         StaticFileInfo info = new StaticFileInfo();
 
-        info.location = staticLocation + "/" + fileName + suffix;
+        info.location = staticLocation + "/" + filePath + "/" + fileName + suffix;
         info.savePath = absPath + "/" + fileName + suffix;
 
         return info;

+ 0 - 10
hsweb-system/hsweb-system-file/src/main/java/org/hswebframework/web/file/web/ReactiveFileController.java

@@ -6,25 +6,15 @@ import org.hswebframework.web.authorization.annotation.Resource;
 import org.hswebframework.web.authorization.annotation.ResourceAction;
 import org.hswebframework.web.file.FileUploadProperties;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.buffer.DataBuffer;
-import org.springframework.core.io.buffer.DataBufferUtils;
 import org.springframework.http.codec.multipart.FilePart;
 import org.springframework.http.codec.multipart.Part;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestPart;
 import org.springframework.web.bind.annotation.RestController;
-import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
 import java.io.File;
-import java.io.IOException;
-import java.nio.channels.AsynchronousFileChannel;
-import java.nio.channels.Channels;
-import java.nio.channels.FileChannel;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
 
 @RestController
 @Resource(id = "file", name = "文件上传")