You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We monkeypatched our app for now with (notice the :encryption => 'AES256'):
# Enable S3 encryption AES256moduleAssetSyncclassStoragedefupload_file(f)# TODO output files in debug logs as asset filename only.one_year=31557600ext=File.extname(f)[1..-1]mime=MultiMime.lookup(ext)gzip_file_handle=nilfile_handle=File.open("#{path}/#{f}")file={:key=>f,:body=>file_handle,:public=>true,:content_type=>mime,:encryption=>'AES256'}uncompressed_filename=f.sub(/\.gz\z/,'')basename=File.basename(uncompressed_filename,File.extname(uncompressed_filename))assets_to_cache_control=Regexp.union([REGEXP_ASSETS_TO_CACHE_CONTROL] | config.cache_asset_regexps).sourceifbasename.match(Regexp.new(assets_to_cache_control)).present?file.merge!({:cache_control=>"public, max-age=#{one_year}",:expires=>CGI.rfc1123_date(Time.now + one_year)})end# overwrite headers if applicable, you probably shouldn't specific key/body, but cache-control headers etc.iffiles_with_custom_headers.has_key?ffile.merge!files_with_custom_headers[f]log"Overwriting #{f} with custom headers #{files_with_custom_headers[f].to_s}"elsifkey=self.config.custom_headers.keys.detect{|k| f.match(Regexp.new(k))}headers={}self.config.custom_headers[key].eachdo |k,value|
headers[k.to_sym]=valueendfile.merge!headerslog"Overwriting matching file #{f} with custom headers #{headers.to_s}"endgzipped="#{path}/#{f}.gz"ignore=falseifconfig.gzip? && File.extname(f) == ".gz"# Don't bother uploading gzipped assets if we are in gzip_compression mode# as we will overwrite file.css with file.css.gz if it exists.log"Ignoring: #{f}"ignore=trueelsifconfig.gzip? && File.exist?(gzipped)original_size=File.size("#{path}/#{f}")gzipped_size=File.size(gzipped)ifgzipped_size < original_sizepercentage=((gzipped_size.to_f/original_size.to_f)*100).round(2)gzip_file_handle=File.open(gzipped)file.merge!({:key=>f,:body=>gzip_file_handle,:content_encoding=>'gzip'})log"Uploading: #{gzipped} in place of #{f} saving #{percentage}%"elsepercentage=((original_size.to_f/gzipped_size.to_f)*100).round(2)log"Uploading: #{f} instead of #{gzipped} (compression increases this file by #{percentage}%)"endelseif !config.gzip? && File.extname(f) == ".gz"# set content encoding for gzipped files this allows cloudfront to properly handle requests with Accept-Encoding# http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.htmluncompressed_filename=f[0..-4]ext=File.extname(uncompressed_filename)[1..-1]mime=MultiMime.lookup(ext)file.merge!({:content_type=>mime,:content_encoding=>'gzip'})endlog"Uploading: #{f}"endifconfig.aws? && config.aws_rrs?file.merge!({:storage_class=>'REDUCED_REDUNDANCY'})endbucket.files.create(file)unlessignorefile_handle.closegzip_file_handle.closeifgzip_file_handleendendend
Regards
The text was updated successfully, but these errors were encountered:
Hi,
I don't see any proper way to upload files with encryption enabled ?
Cf. http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html
We monkeypatched our app for now with (notice the
:encryption => 'AES256'
):Regards
The text was updated successfully, but these errors were encountered: