fix:优化航线管理航线上传逻辑
This commit is contained in:
parent
8c13532322
commit
1e18bf59b5
|
|
@ -13,8 +13,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* 文件请求处理
|
||||
*
|
||||
|
|
@ -66,11 +64,12 @@ public class SysFileController {
|
|||
* 文件流上传请求
|
||||
*/
|
||||
@PostMapping("uploadStream")
|
||||
public R<String> uploadFileByStream(String filename, String extension, ByteArrayOutputStream out) {
|
||||
public R<String> uploadFileByStream(String filename, String extension, String data) {
|
||||
try {
|
||||
return R.ok(sysFileService.uploadFileByStream(filename, extension, out));
|
||||
|
||||
return R.ok(sysFileService.uploadFileByData(filename, extension, data));
|
||||
} catch (Exception e) {
|
||||
log.error("删除文件失败", e);
|
||||
log.error("上传文件失败", e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package com.ruoyi.file.service;
|
|||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
|
|
@ -36,5 +34,5 @@ public interface ISysFileService {
|
|||
* @param out 上传的流
|
||||
* @return 访问地址
|
||||
*/
|
||||
String uploadFileByStream(String filename, String extension, ByteArrayOutputStream out) throws Exception;
|
||||
String uploadFileByData(String filename, String extension, String out) throws Exception;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ public class LocalSysFileServiceImpl implements ISysFileService {
|
|||
* @return 访问地址
|
||||
*/
|
||||
@Override
|
||||
public String uploadFileByStream(String filename, String extension, ByteArrayOutputStream out) throws Exception {
|
||||
try (ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray())) {
|
||||
public String uploadFileByData(String filename, String extension, String out) throws Exception {
|
||||
try (ByteArrayInputStream in = new ByteArrayInputStream(out.getBytes())) {
|
||||
String fileName = FileUploadUtils.extractFilename(filename, extension);
|
||||
return FileUploadUtils.uploadByStream(localFilePath, fileName, in);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public class MinioSysFileServiceImpl implements ISysFileService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String uploadFileByStream(String filename, String extension, ByteArrayOutputStream out) throws Exception {
|
||||
try (ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray())) {
|
||||
public String uploadFileByData(String filename, String extension, String out) throws Exception {
|
||||
try (ByteArrayInputStream in = new ByteArrayInputStream(out.getBytes())) {
|
||||
String fileName = FileUploadUtils.extractFilename(filename, extension);
|
||||
String contentType = FileUploadUtils.getContentType(extension); // 获取文件类型
|
||||
PutObjectArgs args = PutObjectArgs.builder()
|
||||
|
|
|
|||
Loading…
Reference in New Issue