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.PutObjectResult;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -19,9 +20,12 @@ import java.util.UUID;
|
||||
@Component
|
||||
public class AliOSSUtils {
|
||||
// Endpoint以华东1(杭州)为例,其它Region请按实际情况填写。
|
||||
private String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
|
||||
private String bucketName = "inmind-test1";
|
||||
private String region = "cn-hangzhou";
|
||||
@Value("${aliyun.oss.endpoint}")
|
||||
private String endpoint;
|
||||
@Value("${aliyun.oss.bucketName}")
|
||||
private String bucketName;
|
||||
@Value("${aliyun.oss.region}")
|
||||
private String region;
|
||||
|
||||
public String upload(MultipartFile file) throws IOException, ClientException {
|
||||
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-request-size=100MB
|
||||
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