尝试解决以下错误“KeyTooLongError”boto 客户端
不确定应该采取什么措施来消除此错误。
我也遇到过这个错误,由于某种原因,将密钥限制为 1024 个字符对我来说很有效
这导致了错误:
import boto3
s3 = boto3.client("s3")
key = "<some-huge-key>"
response = s3.get_object(Bucket="<my-bucket>", Key=key)
>>> (KeyTooLongError) when calling the GetObject operation: Your key is too long
解决方案:
import boto3
s3 = boto3.client("s3")
key = "<some-huge-key>"
# Limit to exactly 1024 characters
key = key[:1024]
response = s3.get_object(Bucket="<my-bucket>", Key=key)