From 36f8ef06d2a7fb9caf3980308033a472b2f7447a Mon Sep 17 00:00:00 2001 From: Natalia Juszka Date: Mon, 26 Mar 2018 11:55:15 +0200 Subject: [PATCH] Storage/S3: Add md5 checksum --- storage_s3/indico_storage_s3/plugin.py | 6 ++++-- storage_s3/setup.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/storage_s3/indico_storage_s3/plugin.py b/storage_s3/indico_storage_s3/plugin.py index ed4b873..f35b4ee 100644 --- a/storage_s3/indico_storage_s3/plugin.py +++ b/storage_s3/indico_storage_s3/plugin.py @@ -75,8 +75,10 @@ class S3Storage(Storage): def save(self, name, content_type, filename, fileobj): try: - self.client.upload_fileobj(fileobj, self.bucket, name) - return name, '' + fileobject = self._ensure_fileobj(fileobj) + self.client.upload_fileobj(fileobject, self.bucket, name) + checksum = self.client.head_object(Bucket=self.bucket, Key=name)['ETag'][1:-1] + return name, checksum except Exception as e: raise StorageError('Could not save "{}": {}'.format(name, e)), None, sys.exc_info()[2] diff --git a/storage_s3/setup.py b/storage_s3/setup.py index 7f4347d..ab18d1b 100644 --- a/storage_s3/setup.py +++ b/storage_s3/setup.py @@ -21,7 +21,7 @@ from setuptools import setup setup( name='indico-plugin-storage-s3', - version='1.0', + version='1.0-dev', description='S3 storage backend for Indico', url='https://github.com/indico/indico-plugins', license='https://www.gnu.org/licenses/gpl-3.0.txt', @@ -32,7 +32,7 @@ setup( platforms='any', install_requires=[ 'indico>=2.0', - 'boto3>=1.6.5' + 'boto3>=1.6.16,<2.0' ], classifiers=[ 'Environment :: Plugins',