use of com.talend.shaded.com.amazonaws.services.s3.model.Bucket in project camel by apache.
the class AmazonS3ClientMock method listBuckets.
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
ArrayList<Bucket> list = new ArrayList<Bucket>();
Bucket bucket = new Bucket("camel-bucket");
bucket.setOwner(new Owner("Camel", "camel"));
bucket.setCreationDate(new Date());
list.add(bucket);
return list;
}
use of com.talend.shaded.com.amazonaws.services.s3.model.Bucket in project aws-doc-sdk-examples by awsdocs.
the class ListBuckets method main.
public static void main(String[] args) {
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
List<Bucket> buckets = s3.listBuckets();
System.out.println("Your Amazon S3 buckets are:");
for (Bucket b : buckets) {
System.out.println("* " + b.getName());
}
}
use of com.talend.shaded.com.amazonaws.services.s3.model.Bucket in project aws-doc-sdk-examples by awsdocs.
the class CreateBucket method main.
public static void main(String[] args) {
final String USAGE = "\n" + "CreateBucket - create an S3 bucket\n\n" + "Usage: CreateBucket <bucketname>\n\n" + "Where:\n" + " bucketname - the name of the bucket to create.\n\n" + "The bucket name must be unique, or an error will result.\n";
if (args.length < 1) {
System.out.println(USAGE);
System.exit(1);
}
String bucket_name = args[0];
System.out.format("\nCreating S3 bucket: %s\n", bucket_name);
Bucket b = createBucket(bucket_name);
if (b == null) {
System.out.println("Error creating bucket!\n");
} else {
System.out.println("Done!\n");
}
}
use of com.talend.shaded.com.amazonaws.services.s3.model.Bucket in project aws-doc-sdk-examples by awsdocs.
the class CreateBucket method getBucket.
public static Bucket getBucket(String bucket_name) {
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
Bucket named_bucket = null;
List<Bucket> buckets = s3.listBuckets();
for (Bucket b : buckets) {
if (b.getName().equals(bucket_name)) {
named_bucket = b;
}
}
return named_bucket;
}
use of com.talend.shaded.com.amazonaws.services.s3.model.Bucket in project tutorials by eugenp.
the class S3Application method main.
public static void main(String[] args) throws IOException {
// set-up the client
AmazonS3 s3client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion(Regions.US_EAST_2).build();
AWSS3Service awsService = new AWSS3Service(s3client);
bucketName = "baeldung-bucket";
// creating a bucket
if (awsService.doesBucketExist(bucketName)) {
System.out.println("Bucket name is not available." + " Try again with a different Bucket name.");
return;
}
awsService.createBucket(bucketName);
// list all the buckets
for (Bucket s : awsService.listBuckets()) {
System.out.println(s.getName());
}
// deleting bucket
awsService.deleteBucket("baeldung-bucket-test2");
// uploading object
awsService.putObject(bucketName, "Document/hello.txt", new File("/Users/user/Document/hello.txt"));
// listing objects
ObjectListing objectListing = awsService.listObjects(bucketName);
for (S3ObjectSummary os : objectListing.getObjectSummaries()) {
System.out.println(os.getKey());
}
// downloading an object
S3Object s3object = awsService.getObject(bucketName, "Document/hello.txt");
S3ObjectInputStream inputStream = s3object.getObjectContent();
FileUtils.copyInputStreamToFile(inputStream, new File("/Users/user/Desktop/hello.txt"));
// copying an object
awsService.copyObject("baeldung-bucket", "picture/pic.png", "baeldung-bucket2", "Document/picture.png");
// deleting an object
awsService.deleteObject(bucketName, "Document/hello.txt");
// deleting multiple objects
String[] objkeyArr = { "Document/hello2.txt", "Document/picture.png" };
DeleteObjectsRequest delObjReq = new DeleteObjectsRequest("baeldung-bucket").withKeys(objkeyArr);
awsService.deleteObjects(delObjReq);
}
Aggregations