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

[storages] Add fs_importing support

parent f2eb4621f0b2
......@@ -59,6 +59,18 @@ class S3Storage(Storage):
def entity_added(self, entity, attr):
"""an entity using this storage for attr has been added"""
if entity._cw.transaction_data.get('fs_importing'):
# fs_importing allows to change S3 key saved in database
entity._cw_dont_cache_attribute(attr, repo_side=True)
key = entity.cw_edited[attr].getvalue()
if PY3:
key = key.decode('utf-8')
try:
return Binary(self.s3cnx.get_object(
Bucket=self.bucket, Key=key)['Body'].read())
except Exception:
return None
binary = entity.cw_edited.pop(attr)
if binary is not None:
key = self.get_s3_key(entity, attr)
......
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