From 34c2e2a36f7818690d2edfc903985bfc7960b172 Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 22 May 2019 15:42:06 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=20=E4=BC=98=E5=8C=96oss=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../desk/controller/UploadController.java | 15 ++++++++------- .../src/main/resources/application-dev.yml | 7 +++++-- 2 files changed, 13 insertions(+), 9 deletions(-) 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 ebf509f0..c00e2ee9 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 @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import java.util.Objects; + /** * UploadController * @@ -31,16 +33,15 @@ public class UploadController { /** * minio上传demo * - * @param file 上传文件 - * @param bucketName 存储桶名称 + * @param file 上传文件 * @return String */ @SneakyThrows @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); + public R putMinioObject(@RequestParam MultipartFile file) { + minioTemplate.putObject(file); + String objectLink = minioTemplate.getObjectLink(Objects.requireNonNull(file.getOriginalFilename())); + return R.data(objectLink); } /** @@ -53,7 +54,7 @@ public class UploadController { @SneakyThrows @PostMapping("put-qiniu-object") public R putQiniuObject(@RequestParam MultipartFile file, @RequestParam String fileKey) { - Response put = qiniuTemplate.put(file.getInputStream(), fileKey); + Response put = qiniuTemplate.putObject(file, 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 81d021f1..697ee4c6 100644 --- a/blade-service/blade-desk/src/main/resources/application-dev.yml +++ b/blade-service/blade-desk/src/main/resources/application-dev.yml @@ -13,12 +13,15 @@ minio: enable: true tenant-mode: false endpoint: http://127.0.0.1:9000 - access-key: AZINRTAPCMMWMC9G7F3Z - secret-key: sHl2k4+vvmNaSZZdahUOHQwQDZGZl+4+ajRvBX8d + access-key: D99KGE6ZTQXSATTJWU24 + secret-key: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ + bucket-name: bladex qiniu: enable: true + tenant-mode: false endpoint: prv0t4ij6.bkt.clouddn.com access-key: N_Loh1ngBqcJovwiAJqR91Ifj2vgOWHOf8AwBA_h secret-key: AuzuA1KHAbkIndCU0dB3Zfii2O3crHNODDmpxHRS + bucket-name: bladex