Commit c2d7e7f4 authored by Elouan Martinet's avatar Elouan Martinet
Browse files

[storages] Refactor upload code

parent b32b817810c1
...@@ -62,10 +62,11 @@ class S3Storage(Storage): ...@@ -62,10 +62,11 @@ class S3Storage(Storage):
binary = entity.cw_edited.pop(attr) binary = entity.cw_edited.pop(attr)
if binary is not None: if binary is not None:
key = self.get_s3_key(entity, attr) key = self.get_s3_key(entity, attr)
# bytes storage used to store S3's object key # save S3 key
binary_obj = Binary(key.encode('utf-8')) entity.cw_edited.edited_attribute(
entity.cw_edited.edited_attribute(attr, binary_obj) attr, Binary(key.encode('utf-8')))
# required workaround for boto3 bug
# copy Binary value, workaround for boto3 bug
# https://github.com/boto/s3transfer/issues/80 # https://github.com/boto/s3transfer/issues/80
# .read() is required since Binary can't wrap itself # .read() is required since Binary can't wrap itself
buffer = Binary(binary.read()) buffer = Binary(binary.read())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment