use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project deeplearning4j by deeplearning4j.
the class S3Downloader method objectForKey.
/**
* Returns an input stream for the given bucket and key
* @param bucket the bucket to retrieve from
* @param key the key of the objec t
* @return an input stream to the object
*/
public InputStream objectForKey(String bucket, String key) {
AmazonS3 s3 = getClient();
S3Object obj = s3.getObject(bucket, key);
InputStream is = obj.getObjectContent();
return is;
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project deeplearning4j by deeplearning4j.
the class S3Downloader method keysForBucket.
/**
* Return the keys for a bucket
* @param bucket the bucket to get the keys for
* @return the bucket's keys
*/
public List<String> keysForBucket(String bucket) {
AmazonS3 s3 = getClient();
List<String> ret = new ArrayList<>();
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket);
ObjectListing objectListing;
do {
objectListing = s3.listObjects(listObjectsRequest);
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
ret.add(objectSummary.getKey());
}
listObjectsRequest.setMarker(objectListing.getNextMarker());
} while (objectListing.isTruncated());
return ret;
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project deeplearning4j by deeplearning4j.
the class S3Downloader method download.
public void download(String bucket, String key, OutputStream to) throws IOException {
AmazonS3 s3 = getClient();
S3Object obj = s3.getObject(bucket, key);
InputStream is = obj.getObjectContent();
BufferedOutputStream bos = new BufferedOutputStream(to);
IOUtils.copy(is, bos);
bos.close();
is.close();
obj.close();
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project deeplearning4j by deeplearning4j.
the class S3Downloader method buckets.
/**
* Returns the list of buckets in s3
* @return the list of buckets
*/
public List<String> buckets() {
List<String> ret = new ArrayList<>();
AmazonS3 s3 = getClient();
List<Bucket> buckets = s3.listBuckets();
for (Bucket b : buckets) ret.add(b.getName());
return ret;
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project deeplearning4j by deeplearning4j.
the class S3Downloader method download.
public void download(String bucket, String key, File to) throws IOException {
AmazonS3 s3 = getClient();
S3Object obj = s3.getObject(bucket, key);
InputStream is = obj.getObjectContent();
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(to));
IOUtils.copy(is, bos);
bos.close();
is.close();
obj.close();
}
Aggregations