Sha256: 3642c5f476dd525da933651645f20bc58981c03b1d6759eebf2b1f100aaa76a6
Contents?: true
Size: 1.06 KB
Versions: 8
Compression:
Stored size: 1.06 KB
Contents
module Uploadbox module ImgHelper def s3_policy Base64.encode64(policy_data.to_json).gsub("\n", "") end def s3_signature Base64.encode64( OpenSSL::HMAC.digest( OpenSSL::Digest::Digest.new('sha1'), CarrierWave::Uploader::Base.fog_credentials[:aws_secret_access_key], s3_policy ) ).gsub("\n", "") end def img(source, options={}) if source.respond_to?(:url) and source.respond_to?(:width) and source.respond_to?(:height) image_tag(source.url, {width: source.width, height: source.height}.merge(options)) else image_tag(source, options) end end private def policy_data { expiration: 10.hours.from_now.utc.iso8601, conditions: [ ["starts-with", "$key", 'uploads/'], ["content-length-range", 0, 500.megabytes], ["starts-with","$content-type",""], {bucket: CarrierWave::Uploader::Base.fog_directory}, {acl: 'public-read'} ] } end end end
Version data entries
8 entries across 8 versions & 1 rubygems