use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.
the class SetAcl method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <bucketName> <id> \n\n" + "Where:\n" + " bucketName - the Amazon S3 bucket to grant permissions on. \n" + " id - the ID of the owner of this bucket (you can get this value from the AWS Management Console).\n";
if (args.length != 3) {
System.out.println(USAGE);
System.exit(1);
}
String bucketName = args[0];
String id = args[1];
System.out.format("Setting access \n");
System.out.println(" in bucket: " + bucketName);
Region region = Region.US_WEST_2;
S3Client s3 = S3Client.builder().region(region).build();
setBucketAcl(s3, bucketName, id);
System.out.println("Done!");
s3.close();
}
use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.
the class SetBucketPolicy method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <bucketName> <polFile>\n\n" + "Where:\n" + " bucketName - the Amazon S3 bucket to set the policy on.\n" + " polFile - a JSON file containing the policy (see the Amazon S3 Readme for an example). \n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String bucketName = args[0];
String polFile = args[1];
String policyText = getBucketPolicyFromFile(polFile);
Region region = Region.US_EAST_1;
S3Client s3 = S3Client.builder().region(region).build();
setPolicy(s3, bucketName, policyText);
s3.close();
}
use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.
the class CreateBucketAsync method main.
public static void main(String[] args) throws URISyntaxException {
final String USAGE = "\n" + "Usage:\n" + " <bucketName> \n\n" + "Where:\n" + " bucketName - the name of the bucket to create. The bucket name must be unique, or an error occurs.\n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String bucketName = args[0];
System.out.format("Creating a bucket named %s\n", bucketName);
Region region = Region.US_EAST_1;
S3AsyncClient s3AsyncClient = S3AsyncClient.builder().region(region).build();
createBucket(s3AsyncClient, bucketName);
}
use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.
the class S3AsyncOps method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " S3AsyncOps <bucketName> <key> <path>\n\n" + "Where:\n" + " bucketName - the name of the Amazon S3 bucket (for example, bucket1). \n\n" + " key - the name of the object (for example, book.pdf). \n" + " path - the local path to the file (for example, C:/AWS/book.pdf). \n";
if (args.length != 3) {
System.out.println(USAGE);
System.exit(1);
}
String bucketName = args[0];
String key = args[1];
String path = args[2];
Region region = Region.US_WEST_2;
S3AsyncClient client = S3AsyncClient.builder().region(region).build();
PutObjectRequest objectRequest = PutObjectRequest.builder().bucket(bucketName).key(key).build();
// Put the object into the bucket
CompletableFuture<PutObjectResponse> future = client.putObject(objectRequest, AsyncRequestBody.fromFile(Paths.get(path)));
future.whenComplete((resp, err) -> {
try {
if (resp != null) {
System.out.println("Object uploaded. Details: " + resp);
} else {
// Handle error
err.printStackTrace();
}
} finally {
// Only close the client when you are completely done with it
client.close();
}
});
future.join();
}
use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.
the class ListAlgorithms method main.
public static void main(String[] args) {
Region region = Region.US_WEST_2;
SageMakerClient sageMakerClient = SageMakerClient.builder().region(region).build();
listAlgs(sageMakerClient);
sageMakerClient.close();
}
Aggregations