代码拉取完成,页面将自动刷新
<dependency>
<groupId>com.jvm123</groupId>
<artifactId>minio-spring-boot-starter</artifactId>
<version>1.2.1</version>
</dependency>
file:
store:
minio:
endpoint: http://192.168.80.106:9000
bucket: test
access-key: admin
secret-key: admin123
tmp-dir: ./tmp/
tmp-clean: true
tmp-first-clean-time: 2020-1-17 11:45:00
tmp-clean-period: 12960000
tmp-alive-duration: 12960000
如果不配置默认bucket,则需要在使用时指定。存储时指定的bucket如果不存在,则会自动创建。
tmp-dir 为api中返回File类型的缓存目录,这个目录会按照FIFO规则定时清理。如果使用返回InputStream的api,则不会有缓存。
兼容v1.0.0的所有用发,新增的示例如下:
package com.jvm123.demo;
import com.jvm123.minio.service.FileStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
* @author yawn http://jvm123.com
* 2020/1/15 17:17
*/
@RestController
public class TestController {
@Autowired
FileStoreService fileStoreService;
@GetMapping("test2")
public void test2(HttpServletResponse response) throws IOException {
String bucketName = "demo-bucket";
// 创建bucket
boolean created = fileStoreService.createBucket(bucketName);
// 存储文件
String saved = fileStoreService.save(bucketName, new File("C:\\asd.txt"), "a.txt");
// 删除文件
boolean deleted = fileStoreService.delete(bucketName, "a.txt");
// 获取文件
File file = fileStoreService.getFile(bucketName, "a.txt");
// 获取输入流
InputStream inputStream = fileStoreService.getStream(bucketName, "a.txt");
// 下载
response.addHeader("Content-Disposition","attachment;filename=a.txt");
ServletOutputStream os = response.getOutputStream();
fileStoreService.writeTo(bucketName, "a.txt", os);
}
}
v1.0.0 常用功能的实现
v1.1.0 常用功能的实现
v1.2.1
<dependency>
<groupId>com.jvm123</groupId>
<artifactId>minio-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
file:
store:
minio:
endpoint: http://192.168.80.106:9000
bucket: test
access-key: admin
secret-key: admin123
tmp-dir: ./tmp/
tmp-clean: true
tmp-first-clean-time: 2020-1-17 11:45:00
tmp-clean-period: 12960000
tmp-alive-duration: 12960000
如果不配置默认bucket,则需要在使用时指定。存储时指定的bucket如果不存在,则会自动创建。
tmp-dir 为api中返回File类型的缓存目录,这个目录会按照FIFO规则定时清理。如果使用返回InputStream的api,则不会有缓存。
兼容v1.0.0的所有用发,新增的示例如下:
package com.jvm123.demo;
import com.jvm123.minio.service.FileStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
* @author yawn http://jvm123.com
* 2020/1/15 17:17
*/
@RestController
public class TestController {
@Autowired
FileStoreService fileStoreService;
@GetMapping("test2")
public void test2(HttpServletResponse response) throws IOException {
String bucketName = "demo-bucket";
// 创建bucket
boolean created = fileStoreService.createBucket(bucketName);
// 存储文件
String saved = fileStoreService.save(bucketName, new File("C:\\asd.txt"), "a.txt");
// 删除文件
boolean deleted = fileStoreService.delete(bucketName, "a.txt");
// 获取文件
File file = fileStoreService.getFile(bucketName, "a.txt");
// 获取输入流
InputStream inputStream = fileStoreService.getStream(bucketName, "a.txt");
// 下载
response.addHeader("Content-Disposition","attachment;filename=a.txt");
ServletOutputStream os = response.getOutputStream();
fileStoreService.writeTo(bucketName, "a.txt", os);
}
}
v1.0.0 常用功能的实现
v1.1.0 常用功能的实现
<dependency>
<groupId>com.jvm123</groupId>
<artifactId>minio-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
file:
store:
minio:
endpoint: http://petdy.cn:9000
bucket: test-bucket
access-key: admin
secret-key: admin
tmp-dir: ./tmp/
package com.jvm123.demo;
import com.jvm123.minio.service.FileStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
* @author yawn http://jvm123.com
* 2020/1/15 17:17
*/
@RestController
public class TestController {
@Autowired
FileStoreService fileStoreService;
@GetMapping("get")
public void get(HttpServletResponse response) throws IOException {
// 存储文件
fileStoreService.save(new File("C:\\asd.txt"), "a.txt");
// 获取文件
File file = fileStoreService.getFile("a.txt");
// 获取输入流
InputStream inputStream = fileStoreService.getStream("a.txt");
// 下载
response.addHeader("Content-Disposition","attachment;filename=a.txt");
ServletOutputStream os = response.getOutputStream();
fileStoreService.download("a.txt", os);
}
}
v1.0.0 常用功能的实现
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。