|
|
|
@@ -9,6 +9,8 @@ import org.springframework.context.annotation.Primary; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
/** |
|
|
|
* Minio 文件存储 |
|
|
|
* |
|
|
|
@@ -33,6 +35,8 @@ public class MinioSysFileServiceImpl implements ISysFileService { |
|
|
|
@Override |
|
|
|
public String uploadFile(MultipartFile file) throws Exception { |
|
|
|
String fileName = FileUploadUtils.extractFilename(file); |
|
|
|
|
|
|
|
//fileName = URLEncoder.encode(fileName, "UTF-8"); |
|
|
|
System.out.println("Minio filename:" + fileName); |
|
|
|
PutObjectArgs args = PutObjectArgs.builder() |
|
|
|
.bucket(minioConfig.getBucketName()) |
|
|
|
@@ -42,6 +46,10 @@ public class MinioSysFileServiceImpl implements ISysFileService { |
|
|
|
.build(); |
|
|
|
client.putObject(args); |
|
|
|
System.out.println("Minio 文件上传成功"); |
|
|
|
// 获取fileName的最后一个'/'的位置的字符串,并用URLEncoder进行UTF-8编码后,再拼接到fileName中 |
|
|
|
String splitStr = fileName.substring(fileName.lastIndexOf("/") + 1); |
|
|
|
splitStr = URLEncoder.encode(splitStr, "UTF-8"); |
|
|
|
fileName = fileName.substring(0, fileName.lastIndexOf("/") + 1) + splitStr; |
|
|
|
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; |
|
|
|
} |
|
|
|
|
|
|
|
|