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
Log on to the OSS console.
In the left-side navigation pane, choose Data Service > OSS on CloudBox Buckets, and click Create Bucket in the upper-left corner.
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:
|
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 |
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.
|
Cloud Box ID | The ID of the purchased cloud box. |
Versioning | Specifies whether to enable versioning. Valid values:
|
Encryption Method | The method that is used to encrypt objects in the OSS on CloudBox bucket. Valid values:
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.