我正在尝试在IBM Cloud Object Storage中创建两个存储桶:
cos = ibm_boto3.resource('s3',
ibm_api_key_id=cos_credentials['apikey'],
ibm_service_instance_id=cos_credentials['resource_instance_id'],
ibm_auth_endpoint=auth_endpoint,
config=Config(signature_version='oauth'),
endpoint_url=service_endpoint)
import datetime
# valid bucket format is ^[a-zA-Z0-9.\-_]{1,255}$
bucket_uid = datetime.datetime.now().isoformat().replace(':', '')
buckets = ['training-data-' + bucket_uid, 'training-results-' + bucket_uid]
for bucket in buckets:
if not cos.Bucket(bucket) in cos.buckets.all():
print('Creating bucket "{}"...'.format(bucket))
try:
cos.create_bucket(Bucket=bucket)
except ibm_boto3.exceptions.ibm_botocore.client.ClientError as e:
print('Error: {}.'.format(e.response['Error']['Message']))
返回错误:
Creating bucket "training-data-2018-07-11T090425.347277"...
Error: Container training-data-2018-07-11T090425.347277 creation failed, vault name invalid.
Creating bucket "training-results-2018-07-11T090425.347277"...
Error: Container training-results-2018-07-11T090425.347277 creation failed, vault name invalid.
这是什么问题?为什么保管库名称无效?
如果我将bucket_id更改为“ 12345”,则表示创建了存储桶。
答案 0 :(得分:0)
存储桶名称长度是问题所在。
缩短时间戳是我的答案。很遗憾该错误消息没有提供更多信息。