代码调整
This commit is contained in:
@@ -4,6 +4,7 @@ import io.minio.MinioClient;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -12,8 +13,9 @@ import org.springframework.stereotype.Component;
|
||||
* @date 2022年10月16日 18:37
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "min.io")
|
||||
public class MinIoProperties {
|
||||
public class MinIossProperties {
|
||||
|
||||
/**
|
||||
* Minio 服务端ip
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.minioss.util;
|
||||
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minioss.config.MinIoProperties;
|
||||
import com.njcn.minioss.config.MinIossProperties;
|
||||
import io.minio.*;
|
||||
import io.minio.http.Method;
|
||||
import io.minio.messages.Bucket;
|
||||
@@ -9,8 +9,10 @@ import io.minio.messages.DeleteError;
|
||||
import io.minio.messages.DeleteObject;
|
||||
import io.minio.messages.Item;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -19,8 +21,7 @@ import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({MinIoProperties.class})
|
||||
@Component
|
||||
public class MinIoUtils {
|
||||
|
||||
@Resource
|
||||
@@ -339,6 +340,7 @@ public class MinIoUtils {
|
||||
|
||||
/**
|
||||
* 文件流上传
|
||||
*
|
||||
* @param inputStream 文件流
|
||||
* @param bucketName 桶名
|
||||
* @param directory image/
|
||||
@@ -363,19 +365,15 @@ public class MinIoUtils {
|
||||
|
||||
|
||||
/**
|
||||
* @param response
|
||||
* @return java.lang.String
|
||||
* @return InputStream 文件流
|
||||
* @Description 下载文件
|
||||
*/
|
||||
// public void download(HttpServletResponse response, String bucketName, String minFileName) throws Exception {
|
||||
// InputStream fileInputStream = instance.getObject(GetObjectArgs.builder()
|
||||
// .bucket(bucketName)
|
||||
// .object(minFileName).build());
|
||||
// response.setHeader("Content-Disposition", "attachment;filename=" + minFileName);
|
||||
// response.setContentType("application/force-download");
|
||||
// response.setCharacterEncoding("UTF-8");
|
||||
// IOUtils.copy(fileInputStream, response.getOutputStream());
|
||||
// }
|
||||
public InputStream downloadStream(String bucketName, String minFileName) throws Exception {
|
||||
return instance.getObject(GetObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(minFileName).build());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.njcn.minioss.config.MinIoProperties,\
|
||||
com.njcn.minioss.config.MinIossProperties,\
|
||||
com.njcn.minioss.util.MinIoUtils
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user