Amazon S3 - List all the zip files recursively within S3 bucket using Java API -
i've s3 bucket on amazon , trying list of zip files located within folders under bucket recursively.
for e.g, zip files located shown below :
bucket1/${user1}/${date1}/abc.zip bucket1/${user2}/${date2}/xyz.zip bucket1/${user3}/${date3}/mno.zip bucketname=bucket1 prefix=bucket1/
below code :
final amazons3 amazons3 = amazons3utils.getamazons3client(); final listobjectsrequest listobjectsrequest = new listobjectsrequest().withbucketname("bucket1") .withprefix("bucket1/"); objectlisting current = amazons3.listobjects(listobjectsrequest); final list<s3objectsummary> keylist = current.getobjectsummaries(); while (current.istruncated()) { keylist.addall(current.getobjectsummaries()); current = amazons3.listnextbatchofobjects(current); } keylist.addall(current.getobjectsummaries()); for(s3objectsummary summary : keylist) { system.out.println(summary.getkey()); }
but empty list.
am doing wrong ? there way recursively list of zip files bucket ?
only thing can see getting connection s3 bucket.try following , may help
awscredentials credentials = new basicawscredentials(accesskeyid,secretaccesskey); amazons3 s3client = new amazons3client(credentials); objectlisting objects = s3client.listobjects(listobjectrequest);
Comments
Post a Comment