mirror of
https://github.com/zulip/zulip.git
synced 2026-07-03 21:10:12 +08:00
Include realm ID in S3 metadata on uploaded files.
(imported from commit 7d41ec94991bd257485116791a0d1ef2c22d9b37)
This commit is contained in:
parent
e3b2e7ece2
commit
fb4eae9e2b
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user