Reputation: 41
I want to use ovh s3 api to access ovh cloud storage in java using keystore, secret key , consumer key and region. So using that i can upload files on ovh cloud storage .
Upvotes: 0
Views: 1962
Reputation: 436
Before using Java to connect to your backend I suggest you validate your connection with the CLI client like following
Get your tokens you will need to generated them as explained in this documentation : https://docs.ovh.com/gb/en/storage/getting_started_with_the_swift_S3_API/
Important steps are :
openrc
fileuser@host:~$ source <user_name>-openrc.sh
ec2
credentialsuser@host:~$ openstack ec2 credentials create
user@host:~$ cat ~/.aws/credentials
[default]
aws_access_key_id = <access_key>
aws_secret_access_key = <secret_key>
user@host:~$ cat ~/.aws/config
[plugins]
endpoint = awscli_plugin_endpoint
[profile default]
region = <region>
s3 =
endpoint_url = https://s3.<region>.cloud.ovh.net
signature_version = s3v4
s3api =
endpoint_url = https://s3.<region>.cloud.ovh.net
Validate the connectivity of your bucket by listing your OVHcloud storage objects.
aws --profile default s3 ls
Then you can connect from java code you can use the code sample from this post answer 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));
Important thing is to provide the endpoint/region because sdk defaults to US_WEST
region
Upvotes: 1