diff --git a/blade-service/blade-desk/pom.xml b/blade-service/blade-desk/pom.xml
index d3a9b84f..fd57e14d 100644
--- a/blade-service/blade-desk/pom.xml
+++ b/blade-service/blade-desk/pom.xml
@@ -47,6 +47,11 @@
blade-starter-minio
${bladex.tool.version}
+
+ org.springblade
+ blade-starter-qiniu
+ ${bladex.tool.version}
+
diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/UploadController.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/UploadController.java
index 2aeaf76b..ebf509f0 100644
--- a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/UploadController.java
+++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/UploadController.java
@@ -1,10 +1,17 @@
package org.springblade.desk.controller;
+import com.qiniu.http.Response;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springblade.core.minio.MinioTemplate;
+import org.springblade.core.qiniu.QiniuTemplate;
import org.springblade.core.tool.api.R;
-import org.springframework.web.bind.annotation.*;
+import org.springblade.core.tool.jackson.JsonUtil;
+import org.springblade.core.tool.support.Kv;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/**
@@ -12,25 +19,43 @@ import org.springframework.web.multipart.MultipartFile;
*
* @author Chill
*/
-@RequestMapping("/notice/upload")
@RestController
@AllArgsConstructor
+@RequestMapping("/notice/upload")
public class UploadController {
private MinioTemplate minioTemplate;
+ private QiniuTemplate qiniuTemplate;
+
/**
* minio上传demo
*
- * @param file 上传文件
+ * @param file 上传文件
+ * @param bucketName 存储桶名称
* @return String
*/
@SneakyThrows
- @PostMapping("put-object")
- public R putObject(@RequestParam MultipartFile file, @RequestParam String bucketName) {
+ @PostMapping("put-minio-object")
+ public R putMinioObject(@RequestParam MultipartFile file, @RequestParam String bucketName) {
minioTemplate.putObject(bucketName, file.getOriginalFilename(), file.getInputStream());
String objectUrl = minioTemplate.getObjectUrl(bucketName, file.getOriginalFilename());
return R.data(objectUrl);
}
+ /**
+ * qiniu上传demo
+ *
+ * @param file 上传文件
+ * @param fileKey 上传文件key
+ * @return String
+ */
+ @SneakyThrows
+ @PostMapping("put-qiniu-object")
+ public R putQiniuObject(@RequestParam MultipartFile file, @RequestParam String fileKey) {
+ Response put = qiniuTemplate.put(file.getInputStream(), fileKey);
+ Kv parse = JsonUtil.parse(put.bodyString(), Kv.class);
+ return R.data(parse);
+ }
+
}
diff --git a/blade-service/blade-desk/src/main/resources/application-dev.yml b/blade-service/blade-desk/src/main/resources/application-dev.yml
index 5d5e709d..81d021f1 100644
--- a/blade-service/blade-desk/src/main/resources/application-dev.yml
+++ b/blade-service/blade-desk/src/main/resources/application-dev.yml
@@ -15,3 +15,10 @@ minio:
endpoint: http://127.0.0.1:9000
access-key: AZINRTAPCMMWMC9G7F3Z
secret-key: sHl2k4+vvmNaSZZdahUOHQwQDZGZl+4+ajRvBX8d
+
+qiniu:
+ enable: true
+ endpoint: prv0t4ij6.bkt.clouddn.com
+ access-key: N_Loh1ngBqcJovwiAJqR91Ifj2vgOWHOf8AwBA_h
+ secret-key: AuzuA1KHAbkIndCU0dB3Zfii2O3crHNODDmpxHRS
+