Help Center/ Object Storage Service/ SDK Reference/ Java/ API Overview (SDK for Java)
Updated on 2024-05-11 GMT+08:00

API Overview (SDK for Java)

Bucket APIs

Table 1 lists the bucket-related APIs.

Table 1 Bucket APIs

API

Method

Function

Creating a Bucket (SDK for Java)

obsClient.createBucket(CreateBucketRequest request)

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

Obtaining a Bucket List (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

obsClient.getBucketMetadata(BucketMetadataInfoRequest request)

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

Configuring a Bucket ACL (SDK for Java)

obsClient.setBucketAcl(String bucketName,AccessControlList acl)

Sets an ACL for a bucket.

Obtaining a Bucket ACL (SDK for Java)

obsClient.getBucketAcl(String bucketName)

Returns the ACL of a bucket.

Configuring a Bucket Policy (SDK for Java)

obsClient.setBucketPolicy(String bucketName, String policy)

Sets a bucket policy.

Obtaining the Policy of a Bucket (SDK for Java)

obsClient.getBucketPolicy(String bucketName)

Returns a bucket policy.

Deleting a Bucket Policy (SDK for Java)

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 (SDK for Java)

obsClient.getBucketLocation(String bucketName)

Returns the region where the bucket is created.

Obtaining Storage Information of a Bucket (SDK for Java)

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 (SDK for Java)

obsClient.setBucketQuota(String bucketName, BucketQuota bucketQuota)

Sets a limit on the capacity of a bucket.

Obtaining a Bucket Storage Quota (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

obsClient.getBucketStoragePolicy(String bucketName)

Returns the storage class of a bucket.

Configuring an Inventory Rule (SDK for Java)

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 (SDK for Java)

obsClient.getInventoryConfiguration(GetInventoryConfigurationRequest request)

Returns a bucket inventory rule specified by the rule ID.

Listing Inventory Rules (SDK for Java)

obsClient.listInventoryConfiguration(ListInventoryConfigurationRequest request)

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

Deleting an Inventory Rule (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

obsClient.putObject(PutObjectRequest request)

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

Obtaining the Upload Progress (SDK for Java)

PutObjectRequest.setProgressListener(ProgressListener progressListener)

Returns the progress of uploading an object.

Creating a Folder (SDK for Java)

obsClient.putObject(PutObjectRequest request)

Creates a folder in a bucket to categorize the data.

Configuring Object Metadata (SDK for Java)

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 (SDK for Java)

obsClient.initiateMultipartUpload(InitiateMultipartUploadRequest request)

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

Uploading a Part (SDK for Java)

obsClient.uploadPart(UploadPartRequest request)

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

Assembling Parts (SDK for Java)

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 (SDK for Java)

obsClient.abortMultipartUpload(AbortMultipartUploadRequest request)

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

Listing Uploaded Parts (SDK for Java)

obsClient.listParts(ListPartsRequest request)

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

Listing Multipart Uploads (SDK for Java)

obsClient.listMultipartUploads(ListMultipartUploadsRequest request)

Lists ongoing multipart uploads.

Configuring Lifecycle Rules (SDK for Java)

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 (SDK for Java)

obsClient.appendObject(AppendObjectRequest request)

Appends content to an existing object.

Uploading an Object - Resumable (SDK for Java)

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 (SDK for Java)

obsClient.createPostSignature(PostSignatureRequest request)

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

Downloading an Object - Streaming (SDK for Java)

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 - Partial (SDK for Java)

obsClient.getObject(GetObjectRequest request)

Downloads the partial data of an object.

Obtaining the Download Progress (SDK for Java)

GetObjectRequest.setProgressListener(ProgressListener progressListener)

Returns the progress of downloading an object.

Downloading an Object - Conditional (SDK for Java)

obsClient.getObject(GetObjectRequest request)

Returns the objects that meet one or more specified conditions.

Rewriting Response Headers (SDK for Java)

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 (SDK for Java)

obsClient.getObject(GetObjectRequest request)

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

Restoring an Archive Object (SDK for Java)

obsClient.restoreObject(RestoreObjectRequest request)

Restores and downloads an Archive object.

Downloading an Object - Resumable (SDK for Java)

obsClient.downloadFile(DownloadFileRequest request)

Adds the resumable function to the partial download API.

Configuring Object Metadata (SDK for Java)

obsClient.setObjectMetadata(SetObjectMetadataRequest request)

Configures the object metadata.

Obtaining Object Metadata (SDK for Java)

obsClient.getObjectMetadata(GetObjectMetadataRequest request)

Returns the object metadata.

Configuring an Object ACL (SDK for Java)

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 (SDK for Java)

obsClient.getObjectAcl(GetObjectAclRequest request)

Obtains the ACL of an object in a specified bucket.

Listing Objects (SDK for Java)

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 (SDK for Java)

obsClient.deleteObject(DeleteObjectRequest request)

Deletes an object from a bucket.

Batch Deleting Objects (SDK for Java)

obsClient.deleteObjects(DeleteObjectsRequest deleteRequest)

Deletes objects from a bucket in a batch.

(Deleted objects cannot be restored.)

Copying an Object (SDK for Java)

obsClient.copyObject(CopyObjectRequest request)

Creates a copy up to 5 GB for an object.

Copying an Object - Multipart (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

obsClient.setBucketVersioning(final SetBucketVersioningRequest request)

Configures versioning for objects in a bucket.

Obtaining the Versioning Status of a Bucket (SDK for Java)

obsClient.getBucketVersioning(final BaseBucketRequest request)

Returns the versioning status of a bucket.

Obtaining an Object Version (SDK for Java)

obsClient.getObject(GetObjectRequest request)

Returns a specified object version.

Copying an Object Version (SDK for Java)

obsClient.copyObject(CopyObjectRequest request)

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

Restoring a Specific Archive Object Version (SDK for Java)

obsClient.restoreObject(RestoreObjectRequest request)

Restores an Archive object version.

(To download an Archive object version, you need to restore it first.)

Listing Object Versions (SDK for Java)

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 (SDK for Java)

obsClient.setObjectAcl(SetObjectAclRequest request)

Sets an ACL for an object version.

Obtaining the ACL of an Object Version (SDK for Java)

obsClient.getObjectAcl(GetObjectAclRequest request)

Returns the ACL of an object version.

Deleting an Object Version (SDK for Java)

obsClient.deleteObject(DeleteObjectRequest request)

Deletes the ACL of an object version.

Batch Deleting Object Versions (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

obsClient.getBucketLifecycle(final BaseBucketRequest request)

Returns a lifecycle rule of a bucket.

Deleting Lifecycle Rules (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

obsclient.getBucketCors(final BaseBucketRequest request)

Returns a CORS rule of a bucket.

Deleting a CORS Rule (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

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 (SDK for Java)

  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 (SDK for Java)

obsClient.setBucketWebsite(final SetBucketWebsiteRequest request)

Configures website hosting for a bucket.

Obtaining Static Website Hosting Configurations (SDK for Java)

obsClient.getBucketWebsite(final BaseBucketRequest request)

Returns the website configuration of a bucket.

Deleting Static Website Hosting Configurations (SDK for Java)

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 (SDK for Java)

obsClient.setBucketTagging(final SetBucketTaggingRequest request)

Tags a bucket to facilitate CDR filtering and cost analysis.

Obtaining Bucket Tags (SDK for Java)

obsClient.getBucketTagging(final BaseBucketRequest request)

Returns the tags of a bucket.

Deleting Bucket Tags (SDK for Java)

obsClient.deleteBucketTagging(final BaseBucketRequest request)

Deletes the tags of a bucket.