public void processArgs(final String[] args) { final AmazonS3 s3 = setup(args, 1, "bucketName"); final String bucketName = args[0]; try { s3.createBucket(bucketName); } catch (final IOException e) { System.out.println("There was an error creating the bucket."); e.printStackTrace(); } }
@Override public void createContainer(String container, Config config) { super.createContainer(container, config); try { if (!client.doesBucketExist(container)) { client.createBucket(container); } } catch (Exception e) { throw new StorageException(e); } }
private static void createBucket(final String bucketName, final AmazonS3 s3) { try { if (AwsUtils.getUrlBase().contains("archive.org")) { System.out.println("Not creating bucket for URL base: " + AwsUtils.getUrlBase()); return; } } catch (final IOException e1) { e1.printStackTrace(); } final Preferences prefs = Preferences.userRoot(); final String createdBuckets = prefs.get(BUCKETS_KEY, ""); if (!createdBuckets.contains("," + bucketName + ",") && !createdBuckets.endsWith("," + bucketName)) { try { s3.createBucket(bucketName); prefs.put(BUCKETS_KEY, createdBuckets + "," + bucketName); } catch (final IOException e) { System.out.println("Could not create bucket. Already exists?"); e.printStackTrace(); } } }