From 09323e7895ae85319cd8afc51409be43cde90e3d Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Tue, 18 Nov 2025 15:18:16 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
ard-oss/src/main/java/com/ard/oss/service/impl/OssServiceContext.java | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/ard-oss/src/main/java/com/ard/oss/service/impl/OssServiceContext.java b/ard-oss/src/main/java/com/ard/oss/service/impl/OssServiceContext.java
index cc61355..e78de05 100644
--- a/ard-oss/src/main/java/com/ard/oss/service/impl/OssServiceContext.java
+++ b/ard-oss/src/main/java/com/ard/oss/service/impl/OssServiceContext.java
@@ -12,6 +12,7 @@
import io.minio.PutObjectArgs;
import lombok.Cleanup;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -167,7 +168,22 @@
throw new RuntimeException("Upload failed: " + e.getMessage(), e);
}
}
+ @Async("threadPoolTaskExecutor")
+ public String upload(String bucket, String objectKey, InputStream input, String contentType) {
+ try {
+ // 上传文件时指定 Content-Type
+ this.ossService.putObject(bucket, objectKey, input, contentType);
+ // ✅ 构建永久访问 URL
+ String baseUrl = OssConfiguration.endpoint;
+ if (!baseUrl.endsWith("/")) {
+ baseUrl += "/";
+ }
+ return baseUrl + bucket + "/" + objectKey;
+ } catch (Exception e) {
+ throw new RuntimeException("Upload failed: " + e.getMessage(), e);
+ }
+ }
// 获取文件 MIME 类型
public String getMimeTypeByExtension(String fileName) {
// 获取文件扩展名
--
Gitblit v1.9.3