FEATURE: Add S3 etag value to uploads table (#6795)

This commit is contained in:
Vinoth Kannan
2019-01-04 11:46:22 +05:30
committed by Guo Xiang Tan
parent 3a04e04ccb
commit 75dbb98cca
8 changed files with 88 additions and 14 deletions

View File

@ -19,12 +19,14 @@ module FileStore
def store_upload(file, upload, content_type = nil)
path = get_path_for_upload(upload)
store_file(file, path, filename: upload.original_filename, content_type: content_type, cache_locally: true)
url, upload.etag = store_file(file, path, filename: upload.original_filename, content_type: content_type, cache_locally: true)
url
end
def store_optimized_image(file, optimized_image, content_type = nil)
path = get_path_for_optimized_image(optimized_image)
store_file(file, path, content_type: content_type)
url, optimized_image.etag = store_file(file, path, content_type: content_type)
url
end
# options
@ -42,13 +44,14 @@ module FileStore
}
# add a "content disposition" header for "attachments"
options[:content_disposition] = "attachment; filename=\"#{filename}\"" unless FileHelper.is_supported_image?(filename)
# if this fails, it will throw an exception
path.prepend(File.join(upload_path, "/")) if Rails.configuration.multisite
path = @s3_helper.upload(file, path, options)
# return the upload url
File.join(absolute_base_url, path)
# if this fails, it will throw an exception
path, etag = @s3_helper.upload(file, path, options)
# return the upload url and etag
return File.join(absolute_base_url, path), etag
end
def remove_file(url, path)