[英]How can I include a numpy.ndarray as Metadata with boto3?
我想将一个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'
再次AttributeError: 'list' object has no attribute 'encode'
我怎样才能将这个img发送到带有numpy数组(或者我可以转换回numpy数组的某种中等格式)作为元数据的S3?
Welp,看起来像boto3只允许字符串作为元数据,所以你必须使用numpy.array2string(x)
不幸的是,我发现S3的最大元数据大小是2kb,这意味着(256,1)数组太大了!
它作为一个字符串,结果是3135字节
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.