From de03ad78469a19af2b7fceda2d4726ea80bb1bae Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 27 May 2019 20:33:44 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96oss=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springblade/resource/config/OssConfiguration.java | 2 ++ .../org/springblade/resource/endpoint/OssEndpoint.java | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/config/OssConfiguration.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/config/OssConfiguration.java index 65ff40ee..4b31e22a 100644 --- a/blade-ops/blade-resource/src/main/java/org/springblade/resource/config/OssConfiguration.java +++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/config/OssConfiguration.java @@ -20,6 +20,7 @@ import lombok.AllArgsConstructor; import org.springblade.core.oss.props.OssProperties; import org.springblade.resource.builder.OssBuilder; import org.springblade.resource.mapper.OssMapper; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -30,6 +31,7 @@ import org.springframework.context.annotation.Configuration; */ @Configuration @AllArgsConstructor +@EnableConfigurationProperties(OssProperties.class) public class OssConfiguration { private OssProperties ossProperties; diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java index 5dfde9bd..5cac23b2 100644 --- a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java +++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java @@ -19,6 +19,7 @@ package org.springblade.resource.endpoint; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; import lombok.SneakyThrows; +import org.springblade.core.oss.model.BladeFile; import org.springblade.core.oss.model.OssFile; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; @@ -126,8 +127,8 @@ public class OssEndpoint { @SneakyThrows @PostMapping("/put-file") public R putFile(@RequestParam MultipartFile file) { - ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream()); - return R.data(ossBuilder.template().statFile(file.getOriginalFilename())); + BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream()); + return R.data(ossBuilder.template().statFile(bladeFile.getName())); } /** @@ -140,8 +141,8 @@ public class OssEndpoint { @SneakyThrows @PostMapping("/put-file-by-name") public R putFile(@RequestParam String fileName, @RequestParam MultipartFile file) { - ossBuilder.template().putFile(fileName, file.getInputStream()); - return R.data(ossBuilder.template().statFile(fileName)); + BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); + return R.data(ossBuilder.template().statFile(bladeFile.getName())); } /**