Skip to content

fix: base64 decoding on List of Binary items #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dynamodump/dynamodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ def encoder(self, obj):
json.JSONEncoder.default = encoder


def process_list_type(list):
for elem in list:
if "B" in elem:
elem["B"] = base64.b64decode(elem["B"].encode("utf-8"))


def process_item_types(dct):
for item in dct["Items"]:
for key in item:
val = item[key]
if "B" in val:
item[key]["B"] = base64.b64decode(val["B"].encode("utf-8"))
elif "L" in val:
process_list_type(val["L"])


def _get_aws_client(
Expand Down
7 changes: 7 additions & 0 deletions tests/testTable/data/0001.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
},
"firstName": {
"S": "John"
},
"list": {
"L": [
{
"B": "1234"
}
]
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion tests/testTable/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"ReadCapacityUnits": 1,
"LastDecreaseDateTime": 0.0
},
"TableSizeBytes": 28,
"TableSizeBytes": 39,
"TableName": "testTable",
"TableStatus": "ACTIVE",
"KeySchema": [
Expand Down