Object Storage Service

Products

Object Storage Service

Bucket

Bucket is the container of Object.

Functional Operation of Bucket

Creating Bucket


String bucket_name = "<yourBucketName>";
try {
    // Create buckets.
    s3.createBucket(bucket_name);
    System.out.format("creat OSS bucket %s...",  bucket_name);
} catch (AmazonServiceException e) {
    // Catch exceptions.
    e.printStackTrace();
}

List Bucket in the same region


List<Bucket> buckets = s3.listBuckets();
System.out.println("Your jdcloud OSS buckets are:");
for (Bucket a : buckets) {
    System.out.println("* " + a.getName());
}

List Objects in Bucket


String bucket_name = "<your bucketname>";

System.out.format("Objects in OSS bucket %s:\n", bucket_name);
ListObjectsV2Result result = s3.listObjectsV2(bucket_name);
List<S3ObjectSummary> objects = result.getObjectSummaries();
for (S3ObjectSummary os: objects) {
    System.out.println("* " + os.getKey());
}

Delete Bucket



String bucket_name = "<your bucketname>";

try {
    s3.deleteBucket(bucket_name);
} catch (AmazonServiceException e) {
    System.err.println(e.getErrorMessage());
    System.exit(1);
}

Update Time:2019-07-01 17:59:29