ERROR: Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$"
ERROR: Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$"
当我尝试将图像上传到存储桶时,它抛出错误 "Invalid bucket name "thum.images ": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$""
。
我觉得bucket的名字没什么问题
这是我上传图片的代码:
def upload_thumbnail_image(image_key, thumbnail_image):
thumbnail_image_bucket = os.environ['thumbnail_bucket']
thumbnail_image = #image path
image_key = EFE3-27C8-EEB3-4987/3612d0bc-bdfd-49de-82ee-3e66cbb06807.jpg
try:
new_object = client.upload_file(thumbnail_image, thumbnail_image_bucket, image_key)
return new_object
except Exception as Exc:
set_log(Exc.args[0],True)
"Invalid bucket name "thum.images ": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$""
错误的意思就是它所说的:存储桶名称必须包含一些拼写错误或者是错误的,因为它应该符合以下模式:
^
- 字符串开头
[a-zA-Z0-9.\-_]{1,255}
- 1 到 255 个 ASCII 字母、数字、点、-
或 _
字符
$
- 字符串结尾。
您可以test your bucket names online here。
存储桶名称中不能有空格。
我经常收到此错误,因为在我 copy/paste 来自 S3 网页的存储桶名称之后,存储桶名称中有一个额外的斜杠,例如 aws s3 sync s3:///my-bucket/folder folder
,其中必须有三重反斜杠就两个。
我收到此错误是因为我在包含 s3 路径的 csv 文件的开头有一个不可见的 non-printing 字符(BOM,又名字节顺序标记,又名 U+FEFF)。我能够使用此 python 代码找到它:
print(":".join("{:02x}".format(ord(c)) for c in s3_path))
这导致 feff:
... 在字符串的开头,这让我很失望。您会期望看到类似 6d:79:2d:70:61:74:68
的输出(即两位十六进制数)。
如果您是 运行 Jupyter 代码中的代码,那么请确保您没有将存储桶名称作为 str,如“bucket_name”,它应该只是 bucket_name=name
当我尝试将图像上传到存储桶时,它抛出错误 "Invalid bucket name "thum.images ": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$""
。
我觉得bucket的名字没什么问题
这是我上传图片的代码:
def upload_thumbnail_image(image_key, thumbnail_image):
thumbnail_image_bucket = os.environ['thumbnail_bucket']
thumbnail_image = #image path
image_key = EFE3-27C8-EEB3-4987/3612d0bc-bdfd-49de-82ee-3e66cbb06807.jpg
try:
new_object = client.upload_file(thumbnail_image, thumbnail_image_bucket, image_key)
return new_object
except Exception as Exc:
set_log(Exc.args[0],True)
"Invalid bucket name "thum.images ": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$""
错误的意思就是它所说的:存储桶名称必须包含一些拼写错误或者是错误的,因为它应该符合以下模式:
^
- 字符串开头[a-zA-Z0-9.\-_]{1,255}
- 1 到 255 个 ASCII 字母、数字、点、-
或_
字符$
- 字符串结尾。
您可以test your bucket names online here。
存储桶名称中不能有空格。
我经常收到此错误,因为在我 copy/paste 来自 S3 网页的存储桶名称之后,存储桶名称中有一个额外的斜杠,例如 aws s3 sync s3:///my-bucket/folder folder
,其中必须有三重反斜杠就两个。
我收到此错误是因为我在包含 s3 路径的 csv 文件的开头有一个不可见的 non-printing 字符(BOM,又名字节顺序标记,又名 U+FEFF)。我能够使用此 python 代码找到它:
print(":".join("{:02x}".format(ord(c)) for c in s3_path))
这导致 feff:
... 在字符串的开头,这让我很失望。您会期望看到类似 6d:79:2d:70:61:74:68
的输出(即两位十六进制数)。
如果您是 运行 Jupyter 代码中的代码,那么请确保您没有将存储桶名称作为 str,如“bucket_name”,它应该只是 bucket_name=name