require 'shrine/storage/file_system'require 'shrine/storage/s3'
Shrine.plugin :activerecordShrine.plugin :reformShrine.plugin :determine_mime_typeShrine.plugin :backgrounding
Shrine.storages = { cache: Shrine::Storage::FileSystem.new(Rails.root.join('tmp/uploads'))}
Shrine.storages[:store] = if Rails.env.production? Shrine::Storage::S3.new( access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'), secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'), region: ENV.fetch('AWS_REGION'), bucket: ENV.fetch('AWS_BUCKET'), )else Shrine::Storage::FileSystem.new('public', prefix: 'uploads/store')end
Shrine::Attacher.promote { |data| UploadFilePromotionJob.perform_later(data) }Shrine::Attacher.delete { |data| UploadFileDeletionJob.perform_later(data) }# frozen_string_literal: trueclass UploadFilePromotionJob < ActiveJob::Base queue_as :default
def perform(data) Shrine::Attacher.promote(data) endend
--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine...@googlegroups.com.
To post to this group, send email to ruby-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/869bce4b-12c3-4af9-be9a-2a7869cf3953%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine+unsubscribe@googlegroups.com.