I have a rails app where you can upload images in two different places. Everything is the same between both uploads but they need to go to different S3 buckets. Since the bucket is defined in the Shrine uploader model, do I have to create a new Shrine uploader model for the page with the different bucket? Or is there a way to use the same Shrine uploader model and specify a different bucket?--
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+unsubscribe@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/e8f6326a-32c1-4af4-bd17-192b4502efe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
This looks like a great solution. And you are correct, I am trying to upload two different modles into separate folders(?) within the same bucket and they can share the same cache. But when I try to implement your first suggestion, I get an error that I don't understand:wrong number of arguments (given 2, expected 1)include OutsideImageUploader::Attachment.new(:image, store: :store2)I'll include the relevant code here:require "shrine/storage/s3"
if Rails.env.test?
require "shrine/storage/file_system"
Shrine.storages = {
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"),
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads/store"),
}
else
s3_options = {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION'],
bucket: ENV['S3_BUCKET_NAME'],
}
Shrine.storages = {
cache: Shrine::Storage::S3.new(prefix: "cache", upload_options: {acl: "public-read"}, **s3_options),
store1: Shrine::Storage::S3.new(prefix: "outside_images", upload_options: {acl: "public-read"}, **s3_options),
store2: Shrine::Storage::S3.new(prefix: "images", upload_options: {acl: "public-read"}, **s3_options),
}
end
Shrine.plugin :activerecord
Shrine.plugin :direct_upload
Shrine.plugin :restore_cached_data # for metadata
Shrine.plugin :determine_mime_typeclass Image < ApplicationRecord
include OutsideImageUploader::Attachment.new(:image, store: :store2)class OutsideImage < ApplicationRecord
include OutsideImageUploader::Attachment.new(:outside_image, store: :store1)
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/e8f6326a-32c1-4af4-bd17-192b4502efe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@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/ef296754-a028-4dbd-a84a-7808d3e818b4%40googlegroups.com.
Is it possible that my models are getting loaded before the shrine initializer?No matter how I supply the second argument to Attachment.new I get an error that the storage isn't registered with the Uploader
Shrine.storages = {cache: Shrine::Storage::S3.new(prefix: "cache", upload_options: {acl: "public-read"}, **s3_options),store1: Shrine::Storage::S3.new(prefix: "outside_images", upload_options: {acl: "public-read"}, **s3_options),
image: Shrine::Storage::S3.new(prefix: "images", upload_options: {acl: "public-read"}, **s3_options),}class Image < ApplicationRecord
include OutsideImageUploader::Attachment.new(:image, store: :image)error:storage :image isn't registered on OutsideImageUploader
On Tuesday, September 19, 2017 at 10:26:53 PM UTC-7, Joshua Gorchov wrote:Thank you Janko. I updated shrine in my Gemfile, ran bundle and restarted the server. All of my code is the same as above. Now I'm getting this error:storage "store" isn't registered on OutsideImageUploaderExtracted source (around line #1):<%= image_tag image.image_url(public: true), class: 'img-responsive' %>
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/ef296754-a028-4dbd-a84a-7808d3e818b4%40googlegroups.com.
--
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+unsubscribe@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/7b1f1710-6af4-41ac-96d0-ceae43360fd8%40googlegroups.com.
So is it possible to have uploads from one model to go into a folder within a S3 bucket, and uploads from another model go into a different folder within the same bucket?
So is it possible to have uploads from one model to go into a folder within a S3 bucket,and uploads from another model go into a different folder within the same bucket?
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/7b1f1710-6af4-41ac-96d0-ceae43360fd8%40googlegroups.com.
--
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+unsubscribe@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/ecb1eb62-e8b3-4d2d-a2c4-0efc9ea2066b%40googlegroups.com.