From 647ae0f3d6a7cdb65e13aefdf32664fed7b84c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 9 Nov 2016 11:44:16 +0100 Subject: [PATCH] Fixed create_from_file(filename) bug (should be file obj, not name) --- pillar/api/utils/storage.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pillar/api/utils/storage.py b/pillar/api/utils/storage.py index 63ca608c..aa3deb83 100644 --- a/pillar/api/utils/storage.py +++ b/pillar/api/utils/storage.py @@ -203,6 +203,8 @@ class LocalBlob(Blob): current_app.config['STORAGE_DIR'], self.partial_path) def create_from_file(self, uploaded_file, file_size): + assert hasattr(uploaded_file, 'read') + # Ensure path exists before saving directory = os.path.dirname(self.path) if not os.path.exists(directory): @@ -236,11 +238,11 @@ class LocalBlob(Blob): if current_app.config['TESTING']: log.warning(' - NOT making thumbnails', fname) else: - log.debug(' - Sending thumbnail %s to GCS', fname) + log.debug(' - Sending thumbnail %s to %s', fname, self.bucket) blob = self.bucket.blob(fname) - blob.create_from_file(variation['local_path'], - variation['length']) + with open(variation['local_path'], 'rb') as local_file: + blob.create_from_file(local_file, variation['length']) try: os.unlink(variation['local_path'])