All Products
Search
Document Center

Object Storage Service:Create an OSS on CloudBox bucket

Last Updated:Sep 24, 2024

Object Storage Service (OSS) on CloudBox allows you to monitor and process local data. OSS on CloudBox is suitable for scenarios that require low latency and unified management of multiple branches. Before you use OSS on CloudBox, you must create an OSS on CloudBox bucket.

Prerequisites

  • OSS on CloudBox is supported only in the China (Hangzhou), China (Shenzhen), China (Heyuan), China (Beijing), and China (Chengdu) regions.

  • A cloud box is purchased. For more information, see Purchase a cloud box.

Procedure

Use the OSS console

  1. Log on to the OSS console.

  2. In the left-side navigation pane, choose Data Service > OSS on CloudBox Buckets, and click Create Bucket in the upper-left corner.

  3. In the Create Bucket panel, specify the parameters and click Creation Completed. The following table describes the parameters.

Parameter

Description

Bucket Name

The name of the OSS on CloudBox bucket that you want to create. The name of the OSS on CloudBox bucket must meet the following requirements:

  • The specified name of the OSS on CloudBox bucket cannot be the same as the name of an existing OSS on CloudBox bucket in the cloud box.

  • The name can contain only lowercase letters, digits, and hyphens (-).
  • The name must start and end with a lowercase letter or a digit.
  • The name must be 3 to 63 characters in length.

Region

The region in which the purchased cloud box is located.

Endpoint

The endpoint that is used to access the OSS on CloudBox bucket. After you select the region and ID of the cloud box, an endpoint is automatically associated with the OSS on CloudBox bucket. Endpoints are divided into control endpoints and data endpoints. A control endpoint is in the <Cloudbox-Id>.<Region>.oss-cloudbox-control.aliyuncs.com format and a data endpoint is in the <Cloudbox-Id>.<Region>.oss-cloudbox.aliyuncs.com format.

Storage Class

The storage class of the OSS on CloudBox bucket. Valid value: Standard.

Redundancy Type

The redundancy type of the OSS on CloudBox bucket. Valid value: LRS.

ACL

The access control list (ACL) of the OSS on CloudBox bucket.

  • Private: Only the bucket owner can perform read and write operations on objects in the bucket. Other users cannot access the objects in the bucket.
  • Public Read: Only the bucket owner can perform write operations on objects in the bucket. Other users, including anonymous users, can perform only read operations on the objects in the bucket.
    Warning All users on the Internet can access the objects in the bucket. This may result in unexpected access to the data in your bucket and unexpectedly high fees. Exercise caution when you set your bucket ACL to Public Read.
  • Public Read/Write: All users, including anonymous users, can perform read and write operations on the objects in the bucket.
    Warning All users on the Internet can access objects in the bucket and write data to the bucket. This may result in unexpected access to the data in your bucket and unexpectedly high fees. If a user uploads prohibited data or information, your legitimate interests and rights may be infringed. We recommend that you do not set your bucket ACL to Public Read/Write except in special cases.

Cloud Box ID

The ID of the purchased cloud box.

Versioning

Specifies whether to enable versioning. Valid values:

  • Activate: If you enable versioning for a bucket, objects that are overwritten or deleted in the bucket are stored as previous versions. Versioning allows you to recover objects in a bucket to a previous version, and protects your data from being accidentally overwritten or deleted. For more information, see Overview.
  • Not Activated: If you disable versioning for a bucket, objects that are overwritten or deleted in the bucket are not recovered.

Encryption Method

The method that is used to encrypt objects in the OSS on CloudBox bucket. Valid values:

  • None: Server-side encryption is disabled.
  • OSS-Managed: Keys managed by OSS are used to encrypt objects in the bucket. OSS uses keys to encrypt objects. In addition, OSS uses master keys to encrypt cryptographic keys.

Encryption Algorithm: Only AES-256 is supported.

Use OSS SDKs

You can create an OSS on CloudBox bucket only by using OSS SDK for Java. The version of OSS SDK for Java must be 3.15.0 or later.

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.CreateBucketRequest;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.common.auth.CredentialsProviderFactory;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;

public class Demo {

    public static void main(String[] args) throws Exception {
        // Specify the data endpoint of the OSS on CloudBox bucket. 
        String endpoint = "https://cb-f8z7yvzgwfkl9q0h****.cn-hangzhou.oss-cloudbox.aliyuncs.com";
        // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // Specify the name of the OSS on CloudBox bucket. Example: examplebucket. 
        String bucketName = "examplebucket";
        // Specify the region in which the OSS on CloudBox bucket is located. 
        String region = "cn-hangzhou";
        // Specify the ID of the cloud box. 
        String cloudBoxId = "cb-f8z7yvzgwfkl9q0h****";


        // Create an OSSClient instance. 
        ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
        conf.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(new DefaultCredentialProvider(credentialsProvider.getCredentials()))
                .clientConfiguration(conf)
                .region(region)
                .cloudBoxId(cloudBoxId)
                .build();

        try {
            // Create a CreateBucketRequest object. 
            CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);            
                       
            // Set the ACL of the OSS on CloudBox bucket to public-read. The default ACL is private. 
            //createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);

            // Create the OSS on CloudBox bucket. 
            ossClient.createBucket(createBucketRequest);
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

Use ossutil

You can use ossutil to create an OSS on CloudBox bucket. For more information, see mb.

Use the OSS API

If your business requires a high level of customization, you can directly call the RESTful APIs. To directly call an API, you must include the signature calculation in your code. For more information, see PutBucket.