From fb4eae9e2b8ea96565448e2b5bc48883cdbb0b49 Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Wed, 23 Oct 2013 13:31:40 -0400 Subject: [PATCH] Include realm ID in S3 metadata on uploaded files. (imported from commit 7d41ec94991bd257485116791a0d1ef2c22d9b37) --- zerver/lib/upload.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index 3b272f0424..f760b57691 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -38,14 +38,15 @@ def upload_image_to_s3( bucket_name, file_name, content_type, - user_profile_id, + user_profile, contents, ): conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY) key = Key(conn.get_bucket(bucket_name)) key.key = file_name - key.set_metadata("user_profile_id", str(user_profile_id)) + key.set_metadata("user_profile_id", str(user_profile.id)) + key.set_metadata("realm_id", str(user_profile.realm.id)) if content_type: headers = {'Content-Type': content_type} @@ -70,7 +71,7 @@ def upload_message_image(uploaded_file_name, content_type, file_data, user_profi bucket_name, s3_file_name, content_type, - user_profile.id, + user_profile, file_data ) return "https://%s.s3.amazonaws.com/%s" % (bucket_name, s3_file_name) @@ -87,7 +88,7 @@ def upload_avatar_image(user_file, user_profile, email): bucket_name, s3_file_name, content_type, - user_profile.id, + user_profile, user_file.read(), ) # See avatar_url in avatar.py for URL. (That code also handles the case