Sha256: 508c4d712a947f630a095686189ae584a4e9a10bcfc84186d33251f36e22a781
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
require 'shrine' Shrine.plugin :activerecord Shrine.plugin :presign_endpoint Shrine.plugin :backgrounding if Rails.env.test? s3_options = { access_key_id: 'access_key_id', secret_access_key: 'secret_access_key', region: 'us-east-1', bucket: 'com.bucket' } require "shrine/storage/file_system" Shrine.storages = { cache: Shrine::Storage::FileSystem.new("tmp/uploads", prefix: "cache"), store: Shrine::Storage::FileSystem.new("tmp/uploads", prefix: "store") } else if ENV["S3_ACCESS_KEY_ID"].blank? msg = "You need to configure S3 credentials. See the README.md for more details." puts msg Rails.logger.error msg end s3_options = { access_key_id: ENV.fetch("S3_ACCESS_KEY_ID"), secret_access_key: ENV.fetch("S3_SECRET_ACCESS_KEY"), region: ENV.fetch("S3_REGION"), bucket: ENV.fetch("S3_BUCKET"), } require "shrine/storage/s3" config = Cas::Config.new.uploads Shrine.storages = { cache: Shrine::Storage::S3.new(prefix: config[:cache_directory_prefix], **s3_options), store: Shrine::Storage::S3.new(prefix: config[:store_directory_prefix], **s3_options), } end Shrine::Attacher.promote do |data| Rails.logger.info "Shrine promoting file scheduled" ::Cas::Images::PromoteJob.perform_async(data) end Shrine::Attacher.delete do |data| Rails.logger.info "Shrine deleting file scheduled" ::Cas::Images::DeleteJob.perform_async(data) end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cas-cms-0.1.3 | config/initializers/shrine.rb |
cas-cms-0.1.2 | config/initializers/shrine.rb |
cas-cms-0.1.1 | config/initializers/shrine.rb |
cas-cms-0.1.0 | config/initializers/shrine.rb |