我想使用ovh s3 api访问java中的ovh云存储,使用密钥存储库、密钥、使用者密钥和区域。因此,我可以在ovh云存储上上传文件。
发布于 2022-02-08 18:35:15
在使用Java连接到后端之前,我建议您验证与CLI客户端的连接,如下所示
重要步骤如下:
1. Source your `openrc` file
user@host:~$ source -openrc.sh
1. create your `ec2` credentials
,您将从这个调用中得到一个作为响应的块
user@host:~$ openstack ec2凭据创建
1. edit your aws credentials
确保提供区域并更正到OVHcloud存储的链接
user@host:~$ cat ~/..aws/凭据默认值aws_access_key_id = aws_secret_access_key = user@host:~$ cat ~/..aws/config plugins终结点= awscli_plugin_endpoint配置文件默认区域= s3 = https://s3..cloud.ovh.net signature_version = s3v4 s3api = endpoint_url = https://s3..cloud.ovh.net
配置文件默认的s3 ls
然后,您可以从java代码中连接,您可以使用本文答复Setting AWS S3 Region中的代码示例。
AWSCredentials cred = new BasicAWSCredentials(<accessKey>,<secretKey>);
AmazonS3 s3client = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(cred))
.withClientConfiguration(<your configuration>)
.withRegion(Region.getRegion(Regions.AP_SOUTH_1));
重要的是提供端点/区域,因为sdk默认为US_WEST
。
https://stackoverflow.com/questions/70389565
复制相似问题