get Keys form AWS S3
AmazonS3 s3 = new AmazonS3Client(CRED);
ListObjectsRequest lor = new ListObjectsRequest()
.withBucketName("myBucket")
.withPrefix("code/");
ObjectListing objectListing = s3.listObjects(lor);
for (S3ObjectSummary summary: objectListing.getObjectSummaries()) {
System.out.println(summary.getKey());
}
AWSCredentials creden=new BasicAWSCredentials(accessKey,secretKey);
AmazonS3Client s3Client=new AmazonS3Client(creden);
S3Object object = s3Client.getObject(new GetObjectRequest(
"BucketName", "keyName"));
BufferedReader reader = new BufferedReader(new InputStreamReader(
object.getObjectContent()));
Writer writer = new OutputStreamWriter(new FileOutputStream(file));
while (true) {
String line = reader.readLine();
if (line == null)
break;
writer.write(line + "\n");
}
writer.flush();
writer.close();
reader.close();
http://stackoverflow.com/
沒有留言:
張貼留言