java - AWS S3 using grails -


i trying establish connection aws perofrming basic operations on s3 bucket. following code:

def list(){         awscredentials credentials = new basicawscredentials("access key", "secret key");           amazons3 s3client = new amazons3client(credentials);           string bucketname = "sample-bucket-from-java-code";            system.out.println("listing buckets : ");         (bucket bucket : s3client.listbuckets()) {             system.out.println(" - " + bucket.getname());         }     } 

this gives me error:

request- received error response: com.amazonaws.services.s3.model.amazons3exception: request signature calculated not match signature provided. check key , signing method. 

i have double checked access key , secret key using. cannot figure out issue.

its use "cognito accountid" rather access , secret key. because using cognito accountid has limited access aws, can changed.

// initialize amazon cognito credentials provider.

awscognitocredentialsprovider* credentialsprovider = [awscognitocredentialsprovider                                                       credentialswithregiontype:awsregionuseast1                                                       accountid:@"xxxxxxxxxxx"                                                       identitypoolid:@"xxxxxxxxxxx"                                                       unauthrolearn:@"arn:aws:iam::xxxxxxxxxxx"                                                       authrolearn:nil];  awsserviceconfiguration* configuration = [awsserviceconfiguration configurationwithregion:awsregionuswest2                                                                       credentialsprovider:credentialsprovider];  [awsservicemanager defaultservicemanager].defaultserviceconfiguration = configuration; 

you can find running code blog.

https://tauheeda.wordpress.com/2015/10/15/use-aws-service-to-downloadupload-files-in-your-applications/

do not forget add credential info:

accountid:@“xxxxxxxx” identitypoolid:@”xxxxxxxx-xxxxxxxx” unauthrolearn:@”xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx“


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -