错误:存储桶名称必须与正则表达式“^[a-zA-Z0-9.\-_]{1,255}$"匹配 [英] ERROR: Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$"

查看:17
本文介绍了错误:存储桶名称必须与正则表达式“^[a-zA-Z0-9.\-_]{1,255}$"匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将图像上传到存储桶时,它会抛出错误 存储桶名称无效thum.images":存储桶名称必须与正则表达式匹配^[a-zA-Z0-9.\-_]{1,255}$"".

我认为存储桶名称没有问题.

这是我上传图片的代码:

def upload_thumbnail_image(image_key,thumbnail_image):thumbnail_image_bucket = os.environ['thumbnail_bucket']缩略图图像 = #图像路径image_key = EFE3-27C8-EEB3-4987/3612d0bc-bdfd-49de-82ee-3e66cbb06807.jpg尝试:new_object = client.upload_file(thumbnail_image,thumbnail_image_bucket, image_key)返回新对象除了作为 Exc 的异常:set_log(Exc.args[0],True)

解决方案

The "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 字母、数字、点、-_ 字符
  • $ - 字符串结束.

您可以在这里在线测试您的存储桶名称..>

存储桶名称中不能有空格.

我经常收到此错误,因为在我从 S3 网页复制/粘贴存储桶名称后,存储桶名称中出现了一个额外的斜杠,例如 aws s3 sync s3:///my-bucket/folder folder,其中必须只有两个,而不是三个反斜杠.

When I try to upload images to a bucket, it throw an error "Invalid bucket name "thum.images ": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$"".

I think there is nothing wrong with a bucket name.

This is my code to upload image:

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)

解决方案

The "Invalid bucket name "thum.images ": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$"" error means just what it says: the bucket name must contain some typo or is just wrong as it should meet the following pattern:

  • ^ - start of string
  • [a-zA-Z0-9.\-_]{1,255} - 1 to 255 ASCII letters, digits, dots, - or _ chars
  • $ - end of string.

You may test your bucket names online here.

There can be no whitespaces in the bucket name.

I often get this error because an extra slash gets into the bucket name after I copy/paste the bucket name from the S3 Web page, like aws s3 sync s3:///my-bucket/folder folder, where instead of the triple backslashes there must be just two.

这篇关于错误:存储桶名称必须与正则表达式“^[a-zA-Z0-9.\-_]{1,255}$"匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆