I can't determine from the docs/examples how to store/read binary data from DynamoDB using boto's dynamodb2. How is it done?
My guess was with an item value like { 'B': binary-data }
but that causes an error in the JSON encoder.
You can now store binary data in DynamoDB without having to convert it to a string. You can also store sets composed of binary data. This change will result in greater storage efficiency, along with the potential for lower storage and I/O costs for you.
Binary type attributes can store any binary data, such as compressed text, encrypted data, or images. Whenever DynamoDB compares binary values, it treats each byte of the binary data as unsigned.
Binary large object (BLOB) storage. DynamoDB can store binary items up to 400 KB, but DynamoDB is not generally suited to storing documents or images. A better architectural pattern for this implementation is to store pointers to Amazon S3 objects in a DynamoDB table.
boto provides the Binary class to do this automatically:
from boto.dynamodb2.table import Table
from boto.dynamodb.types import Binary
Table('mytable').put_item({'hashkey': Binary('\x01\x02')})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With