API Overview

Bucket APIs

Table 1 lists the bucket-related APIs.

Table 1 Bucket APIs

API

Method

Function

Creating a Bucket

obsClient.createBucket(CreateBucketRequest request)

Creates a bucket and configures the storage class, region, and ACL for the bucket.

Obtaining a Bucket List

obsClient.listBuckets(ListBucketsRequest request)

Lists all buckets that meet the specified conditions under the current account and returns them in alphabetical order.

Deleting a Bucket

obsClient.deleteBucket(String bucketName)

Deletes an empty bucket (the name of a deleted bucket can be reused at least 30 minutes after the deletion).

Checking Whether a Bucket Exists

obsClient.headBucket(String bucketName)

Checks whether a bucket exists (HTTP status code 200 indicates the bucket exists, while 404 indicates it does not).

Obtaining Bucket Metadata

obsClient.getBucketMetadata(BucketMetadataInfoRequest request)

Returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.

Setting a Bucket ACL

obsClient.setBucketAcl(String bucketName,AccessControlList acl)

Sets an ACL for a bucket.

Obtaining a Bucket ACL

obsClient.getBucketAcl(String bucketName)

Returns the ACL of a bucket.

Configuring a Bucket Policy

obsClient.setBucketPolicy(String bucketName, String policy)

Sets a bucket policy.

Obtaining the Policy of a Bucket

obsClient.getBucketPolicy(String bucketName)

Returns a bucket policy.

Deleting a Bucket Policy

obsClient.deleteBucketPolicy(String bucketName)

Deletes a bucket policy (204 No Content is returned if the policy is deleted successfully or actually does not exist).

Obtaining the Region of a Bucket

obsClient.getBucketLocation(String bucketName)

Returns the region where the bucket is created.

Obtaining Storage Information of a Bucket

obsClient.getBucketStorageInfo(String bucketName)

Returns the storage information about a bucket, including the storage usage and the object count in the bucket.

Configuring a Storage Quota

obsClient.setBucketQuota(String bucketName, BucketQuota bucketQuota)

Sets a limit on the capacity of a bucket.

Obtaining a Bucket Storage Quota

obsClient.getBucketQuota(String bucketName)

Returns the quota of a bucket (0 indicates there is no upper limit to the capacity of the bucket).

Configuring a Storage Class for a Bucket

obsClient.setBucketStoragePolicy(String bucketName, BucketStoragePolicyConfiguration bucketStorage)

Specifies the storage class for a bucket (after the bucket storage class is configured, if you do not specifically configure the storage class for objects in that bucket, those objects will inherit the storage class of the bucket by default).

Obtaining the Storage Class of a Bucket

obsClient.getBucketStoragePolicy(String bucketName)

Returns the storage class of a bucket.

Configuring an Inventory Rule

obsClient.setInventoryConfiguration(SetInventoryConfigurationRequest request)

Configures an inventory rule for a bucket (you can specify the object attributes to include in inventories, such as the object version, size, storage class, tag, encryption status, and last modification).

Obtaining an Inventory Rule

obsClient.getInventoryConfiguration(GetInventoryConfigurationRequest request)

Returns a bucket inventory rule specified by the rule ID.

Listing Inventory Rules

obsClient.listInventoryConfiguration(ListInventoryConfigurationRequest request)

Returns all inventory rules of a bucket in a single response.

Deleting an Inventory Rule

obsClient.deleteInventoryConfiguration(DeleteInventoryConfigurationRequest request)

Deletes a bucket inventory rule specified by the rule ID.

Object APIs

Table 2lists object-related APIs.

Table 2 Object APIs

API

Method

Function

Uploading an Object - Streaming

obsClient.putObject(PutObjectRequest request)

Uploads local files of any type that are smaller than 5 GB to a bucket in streaming mode.

Uploading an Object - File-Based

obsClient.putObject(PutObjectRequest request)

Uploads local files of any type to a bucket over the Internet.

Obtaining the Upload Progress

PutObjectRequest.setProgressListener(ProgressListener progressListener)

Returns the progress of uploading an object.

Creating a Folder

obsClient.putObject(PutObjectRequest request)

Creates a folder in a bucket to categorize the data.

Configuring Object Metadata

obsClient.setObjectMetadata(SetObjectMetadataRequest request)

Sets object attributes (such as the size, MIME type, MD5 value, storage class, or user-defined metadata) when uploading an object in streaming, file-based, or multipart mode, or when copying an object.

Initiating a Multipart Upload

obsClient.initiateMultipartUpload(InitiateMultipartUploadRequest request)

Initiates a multipart upload and returns a globally unique upload ID.

Uploading a Part

obsClient.uploadPart(UploadPartRequest request)

Uploads parts to the bucket based on the upload ID returned by the preceding API.

Assembling Parts

obsClient.completeMultipartUpload(CompleteMultipartUploadRequest request)

Completes a multipart upload based on the multipart upload ID and information about the uploaded parts (including PartNumber and ETag).

Aborting a Multipart Upload

obsClient.abortMultipartUpload(AbortMultipartUploadRequest request)

Aborts a multipart upload specified by the upload ID in a bucket.

Listing Uploaded Parts

obsClient.listParts(ListPartsRequest request)

Returns the uploaded parts in a bucket based on the specified multipart upload ID.

Listing Multipart Uploads

obsClient.listMultipartUploads(ListMultipartUploadsRequest request)

Lists ongoing multipart uploads.

Configuring Lifecycle Rules

obsClient.putObject(PutObjectRequest request)

Configures a lifecycle rule for objects to periodically delete objects in the bucket or transition object storage classes (the object expiration time set using this API takes precedence over that set in a bucket lifecycle rule).

Uploading an Object - Append

obsClient.appendObject(AppendObjectRequest request)

Appends content to an existing object.

Uploading an Object - Resumable

obsClient.uploadFile(UploadFileRequest request)

Provides the resumable function based on the API for multipart uploads to better respond to network disconnections or program crashes.

Uploading an Object - Browser-Based

obsClient.createPostSignature(PostSignatureRequest request)

Uploads an object up to 5 GB in size to a bucket in the HTML form.

Downloading an Object - Streaming

obsClient.getObject(GetObjectRequest request)

Downloads an object from OBS to a local directory or memory (the returned results contain the object name, attributes, input stream, and bucket information).

Downloading an Object - Range-Based

obsClient.getObject(GetObjectRequest request)

Downloads the partial data of an object.

Obtaining the Download Progress

GetObjectRequest.setProgressListener(ProgressListener progressListener)

Returns the progress of downloading an object.

Downloading an Object - Conditional

obsClient.getObject(GetObjectRequest request)

Returns the objects that meet one or more specified conditions.

Rewriting Response Headers

obsClient.getObject(GetObjectRequest request)

Rewrites the following HTTP/HTTPS response headers when downloading an object: Content-Type, Content-Language, Expires, Cache-Control, Content-Disposition, and Content-Encoding.

Obtaining User-defined Metadata

obsClient.getObject(GetObjectRequest request)

Returns the user-defined object metadata after the object is successfully downloaded.

Restoring a Cold Object

obsClient.restoreObject(RestoreObjectRequest request)

Restores and downloads a Cold object.

Downloading an Object - Resumable

obsClient.downloadFile(DownloadFileRequest request)

Adds the resumable function to the partial download API.

Configuring Object Metadata

obsClient.setObjectMetadata(SetObjectMetadataRequest request)

Configures the object metadata.

Obtaining Object Metadata

obsClient.getObjectMetadata(GetObjectMetadataRequest request)

Returns the object metadata.

Configuring an Object ACL

obsClient.setObjectAcl(SetObjectAclRequest request)

Sets an ACL for an object when uploading the object or modifies the ACL of an existing object by calling an ACL API.

Obtaining an Object ACL

obsClient.getObjectAcl(GetObjectAclRequest request)

Obtains the ACL of an object in a specified bucket.

Listing Objects

obsClient.listObjects(ListObjectsRequest request)

Lists some or all objects in a bucket based on the specified prefix, object count, and start position and returns the objects in alphabetical order.

Deleting an Object

obsClient.deleteObject(DeleteObjectRequest request)

Deletes an object from a bucket.

Batch Deleting Objects

obsClient.deleteObjects(DeleteObjectsRequest deleteRequest)

Deletes objects from a bucket in a batch.

(Deleted objects cannot be restored.)

Copying an Object

obsClient.copyObject(CopyObjectRequest request)

Creates a copy up to 5 GB for an object.

Copying an Object - Multipart

obsClient.copyPart(CopyPartRequest request)

Copies parts to a specified bucket based on the multipart upload ID returned in initiating a multipart upload.

Checking Whether an Object Exists

doesObjectExist(final GetObjectMetadataRequest request)

Checks whether an object exists (HTTP status code 200 indicates the object exists, while 404 indicates the object or bucket does not exist).

Temporarily Authorized Access APIs

Table 3 lists the APIs related to temporarily authorized access.

Table 3 Temporarily Authorized Access APIs

API

Method

Function

Accessing OBS Using a Signed URL

obsClient.createTemporarySignature(TemporarySignatureRequest request)

Creates a signed URL and specifies the expiration time for the URL to grant visitors temporary access.

(To allow other users to perform a temporary operation such as upload, you need to generate a URL for the corresponding operation and offer that to users.)

Versioning APIs

Table 4 lists the APIs related to versioning.

Table 4 Versioning APIs

API

Method

Function

Configuring Versioning for a Bucket

obsClient.setBucketVersioning(final SetBucketVersioningRequest request)

Configures versioning for objects in a bucket.

Obtaining the Versioning Status of a Bucket

obsClient.getBucketVersioning(final BaseBucketRequest request)

Returns the versioning status of a bucket.

Obtaining an Object Version

obsClient.getObject(GetObjectRequest request)

Returns a specified object version.

Copying an Object Version

obsClient.copyObject(CopyObjectRequest request)

Creates a copy up to 5 GB for a versioned object.

Restoring a Specific Cold Object Version

obsClient.restoreObject(RestoreObjectRequest request)

Restores a Cold object version.

(To download a Cold object version, you need to restore it first.)

Listing Object Versions

obsClient.listVersions(ListVersionsRequest request)

Lists some or all object versions in a bucket based on the specified prefix, version count, and start position and returns the versions in alphabetical order.

Setting an ACL for an Object Version

obsClient.setObjectAcl(SetObjectAclRequest request)

Sets an ACL for an object version.

Obtaining the ACL of an Object Version

obsClient.getObjectAcl(GetObjectAclRequest request)

Returns the ACL of an object version.

Deleting an Object Version

obsClient.deleteObject(DeleteObjectRequest request)

Deletes the ACL of an object version.

Batch Deleting Object Versions

obsClient.deleteObjects(DeleteObjectsRequest deleteRequest)

Deletes object versions from a bucket in a batch.

(Deleted object versions cannot be restored.)

Lifecycle Rule APIs

Table 5 lists the APIs related to lifecycle rules.

Table 5 Lifecycle Rule APIs

API

Method

Function

Setting Lifecycle Rules

obsClient.setBucketLifecycle(final SetBucketLifecycleRequest request)

Sets a lifecycle rule for a bucket to periodically delete objects in the bucket or transition object storage classes.

Obtaining Lifecycle Rules

obsClient.getBucketLifecycle(final BaseBucketRequest request)

Returns a lifecycle rule of a bucket.

Deleting Lifecycle Rules

obsClient.deleteBucketLifecycle(final BaseBucketRequest request)

Deletes a lifecycle rule of a bucket.

CORS rule APIs

Table 6 lists the APIs related to CORS rules.

Table 6 CORS rule APIs

API

Method

Function

Configuring a CORS Rule

obsclient.setBucketCors(final SetBucketCorsRequest request)

Sets a CORS rule for a bucket (the existing rules will be overwritten by the new ones).

Obtaining a CORS Rule

obsclient.getBucketCors(final BaseBucketRequest request)

Returns a CORS rule of a bucket.

Deleting a CORS Rule

obsclient.deleteBucketCors(final BaseBucketRequest request)

Deletes a CORS rule of a bucket.

Bucket Logging APIs

Table 7 lists the logging APIs.

Table 7 Bucket logging APIs

API

Method

Function

Configuring Logging for a Bucket

obsClient.setBucketLogging(final SetBucketLoggingRequest request)

Enables logging for a source bucket, specifies a target bucket for storing log files, and configures the name prefixes and access permissions for log files.

Obtaining the Logging Configuration of a Bucket

obsClient.getBucketLogging(final BaseBucketRequest request)

Returns the logging configuration of a bucket.

Static Website Hosting APIs

Table 8 lists the APIs related to static website hosting.

Table 8 Static website hosting APIs

API

Method

Function

Hosting Website Files in a Bucket

  1. obsClient.putObject(PutObjectRequest request)

  2. obsClient.setObjectAcl(SetObjectAclRequest acl)

Uploads the files of a static website to a specified bucket in OBS, configures the public read permission for the files, and enables static website hosting for the bucket.

Configuring Static Website Hosting

obsClient.setBucketWebsite(final SetBucketWebsiteRequest request)

Configures website hosting for a bucket.

Obtaining Static Website Hosting Configurations

obsClient.getBucketWebsite(final BaseBucketRequest request)

Returns the website configuration of a bucket.

Deleting Static Website Hosting Configurations

obsClient.deleteBucketWebsite(final BaseBucketRequest request)

Deletes the website configuration of a bucket.

Tagging APIs

Table 9 lists the APIs related to tagging.

Table 9 Tagging APIs

API

Method

Function

Configuring Tags for a Bucket

obsClient.setBucketTagging(final SetBucketTaggingRequest request)

Tags a bucket to facilitate CDR filtering and cost analysis.

Obtaining Bucket Tags

obsClient.getBucketTagging(final BaseBucketRequest request)

Returns the tags of a bucket.

Deleting Bucket Tags

obsClient.deleteBucketTagging(final BaseBucketRequest request)

Deletes the tags of a bucket.