mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2026-04-06 21:54:26 +08:00
v3.31 【增加】字典值反序列增加int类型;【优化】java17版本S3上传文件Bug;【优化】本地文件上传优化文件操作符
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package net.lab1024.sa.base.common.json.deserializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.ObjectCodec;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 字典值为 int类型的 反序列化
|
||||
*
|
||||
* @Author 1024创新实验室: 卓大
|
||||
* @Date 2026-04-05 22:17:53
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
public class DictDataIntDeserializer extends JsonDeserializer<Integer> {
|
||||
|
||||
@Override
|
||||
public Integer deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||
ObjectCodec objectCodec = jsonParser.getCodec();
|
||||
JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);
|
||||
return Integer.parseInt(listOrObjectNode.asText());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import software.amazon.awssdk.core.ResponseBytes;
|
||||
import software.amazon.awssdk.core.sync.RequestBody;
|
||||
import software.amazon.awssdk.core.sync.ResponseTransformer;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.s3.S3Client;
|
||||
import software.amazon.awssdk.services.s3.model.*;
|
||||
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
||||
@@ -116,15 +115,11 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
||||
.contentDisposition("attachment;filename=" + urlEncoderFilename)
|
||||
.acl(acl)
|
||||
.build();
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(inputStream, file.getSize()));
|
||||
s3Client.putObject(putObjectRequest, RequestBody.fromBytes(file.getBytes()));
|
||||
} catch (IOException e) {
|
||||
log.error("文件上传-发生异常:", e);
|
||||
return ResponseDTO.error(SystemErrorCode.SYSTEM_ERROR, "上传失败");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
}
|
||||
// 返回上传结果
|
||||
FileUploadVO uploadVO = new FileUploadVO();
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.UUID;
|
||||
@Slf4j
|
||||
public class FileStorageLocalServiceImpl implements IFileStorageService {
|
||||
|
||||
private static final String FILE_SEPARATOR = "/";
|
||||
|
||||
public static final String UPLOAD_MAPPING = "/upload";
|
||||
|
||||
@@ -78,8 +79,8 @@ public class FileStorageLocalServiceImpl implements IFileStorageService {
|
||||
// 目录不存在,新建
|
||||
directory.mkdirs();
|
||||
}
|
||||
if (!path.endsWith(File.separator)) {
|
||||
path = path + File.separator;
|
||||
if (!path.endsWith(FILE_SEPARATOR)) {
|
||||
path = path + FILE_SEPARATOR;
|
||||
}
|
||||
FileUploadVO fileUploadVO = new FileUploadVO();
|
||||
//原文件名
|
||||
|
||||
Reference in New Issue
Block a user