Create an OSS on CloudBox bucket
OSS on CloudBox lets you monitor and process your local data. It is ideal for use cases that require low latency or unified management of multiple branch offices. Before you use OSS on CloudBox, you must first create an OSS on CloudBox bucket.
Prerequisites
-
OSS on CloudBox is supported only in the China (Hangzhou), China (Shanghai), China (Shenzhen), China (Heyuan), China (Beijing), and China (Chengdu) regions.
-
A cloud box is purchased. For more information, see Purchase a CloudBox.
-
A Virtual Private Cloud (VPC) and a vSwitch are created in the OSS on CloudBox. For more information, see Create a VPC and a vSwitch.
-
A VPC internal network is set up, and a single tunnel is configured to provide secure connection. To apply for this feature, please contact technical support.
Procedure
OSS console
Log on to the OSS console.
In the left-side navigation pane, choose Data Service > OSS on CloudBox Buckets, and then click Create Bucket.
On the Create Bucket page, set the following parameters and click Create.
Parameter
Description
Bucket Name
Enter a name for the bucket. The name must meet the following requirements:
The bucket name must be unique within the CloudBox.
- 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
Select the region where your purchased CloudBox is located.
Endpoint
After you select a region and a Cloud Box ID, an endpoint is automatically assigned to the bucket. OSS on CloudBox provides two types of endpoints: a control endpoint in the
<Cloudbox-Id>.<Region>.oss-cloudbox-control.aliyuncs.comformat and a data endpoint in the<Cloudbox-Id>.<Region>.oss-cloudbox.aliyuncs.comformat.Storage Class
Only Standard is supported.
Redundancy Type
Only LRS is supported.
ACL (Access Control List)
Select the ACL for objects in the 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
Select your CloudBox ID.
Versioning
Select whether to enable versioning.
- 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 Versioning.
- Not Activated: If you disable versioning for a bucket, objects that are overwritten or deleted in the bucket are not recovered.
Encryption Method
Select a server-side encryption method.
None: Disables server-side encryption.
OSS-Managed: OSS encrypts objects by using its own managed keys. For added protection, OSS uses a unique key for each object and encrypts the key itself with a master key for additional protection.
The only supported Encryption Algorithm is AES256.
Alibaba Cloud SDK
To create an OSS on CloudBox bucket by using an SDK, you must use the Alibaba Cloud SDK for Java, version 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 for 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 this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
// Specify the name of the OSS on CloudBox bucket, for example, examplebucket.
String bucketName = "examplebucket";
// Specify the region where the OSS on CloudBox bucket is located.
String region = "cn-hangzhou";
// Specify the Cloud Box ID.
String cloudBoxId = "cb-f8z7yvzgwfkl9q0h****";
// Create an OSSClient instance.
// Call shutdown() to release resources when the client is no longer needed.
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 reached OSS but was rejected with an error response.");
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 a 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();
}
}
}
}ossutil
To create an OSS on CloudBox bucket with ossutil, see put-bucket.
REST API
For advanced customization, you can call the REST API directly. This requires you to write code to calculate the request signature. For more information, see PutBucket.