Browse Source

🎉 增加minio上传demo

test
smallchill 6 years ago
parent
commit
5b34c2dea2
  1. 5
      blade-service/blade-desk/pom.xml
  2. 38
      blade-service/blade-desk/src/main/java/org/springblade/desk/controller/UploadController.java
  3. 9
      blade-service/blade-desk/src/main/resources/application-dev.yml

5
blade-service/blade-desk/pom.xml

@ -42,6 +42,11 @@
<artifactId>blade-flow-api</artifactId>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-minio</artifactId>
<version>${bladex.tool.version}</version>
</dependency>
</dependencies>
<build>

38
blade-service/blade-desk/src/main/java/org/springblade/desk/controller/UploadController.java

@ -0,0 +1,38 @@
package org.springblade.desk.controller;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springblade.core.minio.MinioTemplate;
import org.springblade.core.tool.api.R;
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;
/**
* UploadController
*
* @author Chill
*/
@RequestMapping("upload")
@RestController
@AllArgsConstructor
public class UploadController {
private MinioTemplate minioTemplate;
/**
* minio上传demo
*
* @param file 上传文件
* @return
*/
@SneakyThrows
@PostMapping("put-object")
public R putObject(@RequestParam MultipartFile file) {
minioTemplate.putObject("test233", file.getOriginalFilename(), file.getInputStream());
return R.success("操作成功");
}
}

9
blade-service/blade-desk/src/main/resources/application-dev.yml

@ -7,4 +7,11 @@ spring:
datasource:
url: ${blade.datasource.dev.url}
username: ${blade.datasource.dev.username}
password: ${blade.datasource.dev.password}
password: ${blade.datasource.dev.password}
minio:
enable: true
tenant-mode: false
endpoint: http://127.0.0.1:9000
access-key: AZINRTAPCMMWMC9G7F3Z
secret-key: sHl2k4+vvmNaSZZdahUOHQwQDZGZl+4+ajRvBX8d

Loading…
Cancel
Save