您可以通过API级命令创建存储空间。
注意事项
权限说明
阿里云账号默认拥有全部权限。阿里云账号下的RAM用户或RAM角色默认没有任何权限,需要阿里云账号或账号管理员通过RAM Policy或Bucket Policy授予操作权限。
| API | Action | 说明 | 
| PutBucket | 
 | 创建存储空间(Bucket)。 | 
| 
 | 创建存储空间(Bucket)后,修改Bucket的ACL,需要此操作的权限。 | 
命令格式
ossutil api put-bucket --bucket value [flags]| 参数 | 类型 | 说明 | 
| --acl | string | 指定Bucket的访问权限ACL。 | 
| --bucket | string | Bucket名称。 | 
| --create-bucket-configuration | string | 存储创建Bucket信息的容器。 | 
| --resource-group-id | string | 指定资源组ID。 | 
说明 
put-bucket命令对应API接口PutBucket。关于API中的具体参数含义,请参见PutBucket。
--create-bucket-configuration
--create-bucket-configuration配置选项既支持XML语法也支持JSON语法:
- XML语法: - <?xml version="1.0" encoding="UTF-8"?> <CreateBucketConfiguration> <StorageClass>Standard</StorageClass> <DataRedundancyType>LRS</DataRedundancyType> </CreateBucketConfiguration>
- JSON语法: - { "StorageClass": "Standard", "DataRedundancyType": "LRS" }
说明 
关于支持的全局命令行选项,请参见支持的全局命令行选项。
使用示例
- 创建名为examplebucket的存储空间。 - ossutil api put-bucket --bucket examplebucket
- 创建访问权限为私有,资源组ID为rg-123,名字为examplebucket,存储类型为Standard,数据容灾类型为LRS的存储空间。 - 使用XML配置文件,create-bucket-configuration.xml内容如下: - <?xml version="1.0" encoding="UTF-8"?> <CreateBucketConfiguration> <StorageClass>Standard</StorageClass> <DataRedundancyType>LRS</DataRedundancyType> </CreateBucketConfiguration>- 命令示例如下: - ossutil api put-bucket --bucket examplebucket --acl private --resource-group-id rg-123 --create-bucket-configuration file://create-bucket-configuration.xml
- 使用JSON配置文件,create-bucket-configuration.json内容如下: - { "StorageClass": "Standard", "DataRedundancyType": "LRS" }- 命令示例如下: - ossutil api put-bucket --bucket examplebucket --acl private --resource-group-id rg-123 --create-bucket-configuration file://create-bucket-configuration.json
- 使用JSON配置参数,命令示例如下: - ossutil api put-bucket --bucket examplebucket --acl private --resource-group-id rg-123 --create-bucket-configuration "{\"StorageClass\":\"Standard\",\"DataRedundancyType\":\"LRS\"}"
 
该文章对您有帮助吗?