feat: add image properties, db.changelog and ObjectStorageConfig
This commit is contained in:
parent
06c5e026c9
commit
3009a43e11
@ -0,0 +1,42 @@
|
||||
package com.example.nto.config;
|
||||
|
||||
import com.amazonaws.SdkClientException;
|
||||
import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
||||
import com.amazonaws.auth.BasicAWSCredentials;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Configuration
|
||||
public class ObjectStorageConfig {
|
||||
@Value("${yandex.cloud.region}")
|
||||
private String region;
|
||||
@Value("${yandex.cloud.s3_endpoint}")
|
||||
private String s3Endpoint;
|
||||
|
||||
@Value("${yandex.cloud.bucket}")
|
||||
private String bucketName;
|
||||
@Value("${yandex.cloud.key_id}")
|
||||
private String accessKeyId;
|
||||
@Value("${yandex.cloud.secret_key}")
|
||||
private String secretAccessKey;
|
||||
|
||||
|
||||
public AmazonS3 createAmazonS3() {
|
||||
// Создание клиента AmazonS3 с подключением к Object Storage
|
||||
try {
|
||||
return AmazonS3ClientBuilder.standard()
|
||||
.withEndpointConfiguration(new com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration(s3Endpoint, region))
|
||||
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKeyId, secretAccessKey)))
|
||||
.build();
|
||||
} catch (SdkClientException e) {
|
||||
log.error("Ошибка при создании клиента для хранения объектов с помощью AWS SDK. Причина: {}", e.getMessage());
|
||||
throw new SdkClientException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
7
src/main/resources/application.properties
Normal file
7
src/main/resources/application.properties
Normal file
@ -0,0 +1,7 @@
|
||||
spring.servlet.multipart.max-file-size=10MB
|
||||
spring.servlet.multipart.max-request-size=10MB
|
||||
yandex.cloud.region=ru-central1
|
||||
yandex.cloud.s3_endpoint=https://storage.yandexcloud.net
|
||||
yandex.cloud.key_id=YCAJEIOy-pmwxonO9XLqdhAVI
|
||||
yandex.cloud.secret_key=YCNJMJf9VGP9OmFiPs5XbnfKzzarBl1B1ymGz1uu
|
||||
yandex.cloud.bucket=spring-boot-final-nto-bacet
|
4
src/main/resources/db.changelog/db.changelog-master.xml
Normal file
4
src/main/resources/db.changelog/db.changelog-master.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
||||
</databaseChangeLog>
|
Loading…
x
Reference in New Issue
Block a user