如何使用Spring Boot上传文件和下载文件到LINODE对象存储?
How to Upload files and download files to LINODE object storage using Springboot?
我正在使用SpringBoot进行开发
我需要从 Linode 对象存储(类似于 Amazon s3 存储桶)上传和下载文件。
我没有得到任何用于开发的工件依赖项。我使用 Amazon S3 方法进行开发。但最终出现错误,提示 Keys doesn't match s3.
配置代码如下:
@Configuration
public class WebSecurityConfig {
@Value("${cloud.linode.credentials.access-key}")
private String accessKey;
@Value("${cloud.linode.credentials.secret-key}")
private String accessSecret;
@Value("${cloud.linode.region.static}")
private String region;
@Bean
public AmazonS3 linodeClient() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, accessSecret);
return AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion(region)
.build();
}
}
我该如何解决这个问题?需要 Linode 方法。
您需要使用 withEndpointConfiguration
指定 Linode 端点
@Bean
public AmazonS3 linodeClient() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, accessSecret);
return AmazonS3ClientBuilder
.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
"https://" + region + ".linodeobjects.com", region))
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.build();
}
我正在使用SpringBoot进行开发
我需要从 Linode 对象存储(类似于 Amazon s3 存储桶)上传和下载文件。
我没有得到任何用于开发的工件依赖项。我使用 Amazon S3 方法进行开发。但最终出现错误,提示 Keys doesn't match s3.
配置代码如下:
@Configuration
public class WebSecurityConfig {
@Value("${cloud.linode.credentials.access-key}")
private String accessKey;
@Value("${cloud.linode.credentials.secret-key}")
private String accessSecret;
@Value("${cloud.linode.region.static}")
private String region;
@Bean
public AmazonS3 linodeClient() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, accessSecret);
return AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion(region)
.build();
}
}
我该如何解决这个问题?需要 Linode 方法。
您需要使用 withEndpointConfiguration
@Bean
public AmazonS3 linodeClient() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, accessSecret);
return AmazonS3ClientBuilder
.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
"https://" + region + ".linodeobjects.com", region))
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.build();
}