mirror of
https://github.com/halo-dev/plugin-s3.git
synced 2025-10-15 14:40:46 +00:00
fix: s3 link error when filename renaming enable (#91)
fixes https://github.com/halo-dev/plugin-s3/issues/90 请测试 `上传时重命名文件方式` 选项为**非**保留原文件名时,是否能正常关联s3文件  ```release-note 当上传时文件重命名功能开启时关联S3文件错误 ```
This commit is contained in:
@@ -184,7 +184,7 @@ public class S3LinkServiceImpl implements S3LinkService {
|
||||
.map(headObjectResponse -> {
|
||||
var objectDetail = new S3OsAttachmentHandler.ObjectDetail(
|
||||
new S3OsAttachmentHandler.UploadState(properties,
|
||||
FileNameUtils.extractFileNameFromS3Key(objectKey)),
|
||||
FileNameUtils.extractFileNameFromS3Key(objectKey), false),
|
||||
headObjectResponse);
|
||||
return handler.buildAttachment(properties, objectDetail);
|
||||
})
|
||||
|
@@ -304,7 +304,7 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
||||
Mono<ObjectDetail> upload(UploadContext uploadContext, S3OsProperties properties) {
|
||||
return Mono.using(() -> buildS3Client(properties),
|
||||
client -> {
|
||||
var uploadState = new UploadState(properties, uploadContext.file().filename());
|
||||
var uploadState = new UploadState(properties, uploadContext.file().filename(), true);
|
||||
|
||||
var content = uploadContext.file().content();
|
||||
|
||||
@@ -492,12 +492,14 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
||||
String objectKey;
|
||||
boolean needRemoveMapKey = false;
|
||||
|
||||
public UploadState(S3OsProperties properties, String fileName) {
|
||||
public UploadState(S3OsProperties properties, String fileName, boolean needRandomJudge) {
|
||||
this.properties = properties;
|
||||
this.originalFileName = fileName;
|
||||
|
||||
fileName = FileNameUtils.getRandomFilename(fileName,
|
||||
if (needRandomJudge) {
|
||||
fileName = FileNameUtils.getRandomFilename(fileName,
|
||||
properties.getRandomStringLength(), properties.getRandomFilenameMode());
|
||||
}
|
||||
|
||||
this.fileName = fileName;
|
||||
this.objectKey = properties.getObjectName(fileName);
|
||||
|
Reference in New Issue
Block a user