javaEEday10-tlias管理系统-案例-配置文件-参数配置化
This commit is contained in:
@@ -7,6 +7,7 @@ import com.aliyun.oss.common.comm.SignVersion;
|
|||||||
import com.aliyun.oss.model.PutObjectRequest;
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
import com.aliyun.oss.model.PutObjectResult;
|
import com.aliyun.oss.model.PutObjectResult;
|
||||||
import com.aliyuncs.exceptions.ClientException;
|
import com.aliyuncs.exceptions.ClientException;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -19,9 +20,12 @@ import java.util.UUID;
|
|||||||
@Component
|
@Component
|
||||||
public class AliOSSUtils {
|
public class AliOSSUtils {
|
||||||
// Endpoint以华东1(杭州)为例,其它Region请按实际情况填写。
|
// Endpoint以华东1(杭州)为例,其它Region请按实际情况填写。
|
||||||
private String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
|
@Value("${aliyun.oss.endpoint}")
|
||||||
private String bucketName = "inmind-test1";
|
private String endpoint;
|
||||||
private String region = "cn-hangzhou";
|
@Value("${aliyun.oss.bucketName}")
|
||||||
|
private String bucketName;
|
||||||
|
@Value("${aliyun.oss.region}")
|
||||||
|
private String region;
|
||||||
|
|
||||||
public String upload(MultipartFile file) throws IOException, ClientException {
|
public String upload(MultipartFile file) throws IOException, ClientException {
|
||||||
EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
|
EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
|
||||||
|
|||||||
@@ -11,3 +11,9 @@ mybatis.configuration.map-underscore-to-camel-case=true
|
|||||||
spring.servlet.multipart.max-file-size= 10MB
|
spring.servlet.multipart.max-file-size= 10MB
|
||||||
spring.servlet.multipart.max-request-size=100MB
|
spring.servlet.multipart.max-request-size=100MB
|
||||||
server.port=8080
|
server.port=8080
|
||||||
|
|
||||||
|
aliyun.oss.endpoint=https://oss-cn-hangzhou.aliyuncs.com
|
||||||
|
aliyun.oss.bucketName=inmind-test1
|
||||||
|
aliyun.oss.region=cn-hangzhou
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user