我想将2096字节的numpy数组作为元数据添加到要上传到S3的图像上
我的boto3上传代码是:
s3_response = s3.put_object(
Body=img,
Bucket='mybucket',
Key='test',
Metadata={
'f_vector': frame.f_vector
}
frame.f_vector
是一个numpy.ndarray
这样做时,我得到AttributeError:'numpy.ndarray'对象没有属性'encode'
我尝试使用f_vector.tolist()
将其转换为列表,但随后我再次得到AttributeError: 'list' object has no attribute 'encode'
如何使用numpy数组(或一些我可以转换回numpy数组的中等格式)作为元数据将此img发送到S3中?
答案 0 :(得分:0)
很高兴,看起来boto3仅允许将字符串作为元数据,因此您必须使用numpy.array2string(x)
不幸的是,我发现S3的最大元数据大小为2kb,这意味着(256,1)数组太大!
作为一个字符串,结果是3135个字节