FEATURE: generate (avatar) thumbnails in a background task

FIX: keep the "uploading..." indicator until the server replies via the MessageBus
FIX: text was disapearing when uploading an avatar

PERF: always use a region for S3 (defaults to 'us-east-1')
FEATURE: ApplyCDN middleware when using S3
FIX: use the same pattern to store files on S3 and locally
PERF: keep a local cache of uploads when generating thumbnails
FEATURE: migrate_to_s3 rake task
This commit is contained in:
Régis Hanol
2015-05-25 17:59:00 +02:00
parent 675e2c6e13
commit bb0c2813ac
22 changed files with 303 additions and 94 deletions

View File

@ -18,7 +18,6 @@ class S3Helper
def remove(unique_filename, copy_to_tombstone=false)
bucket = s3_bucket
# copy the file in tombstone
if copy_to_tombstone && @tombstone_prefix.present?
bucket.object(@tombstone_prefix + unique_filename).copy_from(copy_source: "#{@s3_bucket}/#{unique_filename}")
@ -29,19 +28,17 @@ class S3Helper
end
def update_tombstone_lifecycle(grace_period)
return if @tombstone_prefix.blank?
# cf. http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html
s3_resource.client.put_bucket_lifecycle({
bucket: @s3_bucket,
lifecycle_configuration: {
rules: [
{
id: 'purge-tombstone',
status: 'Enabled',
expiration: {
days: grace_period
},
id: "purge-tombstone",
status: "Enabled",
expiration: { days: grace_period },
prefix: @tombstone_prefix
}
]
@ -70,7 +67,6 @@ class S3Helper
bucket
end
def check_missing_site_settings
unless SiteSetting.s3_use_iam_profile
raise Discourse::SiteSettingMissing.new("s3_access_key_id") if SiteSetting.s3_access_key_id.blank?