Reputation: 1103
Hi I am trying to upload images directly to S3 using refile gem
project.rb looks like
class Project < ActiveRecord::Base
has_many :photos, :class_name => "Project::Photo", dependent: :destroy
accepts_attachments_for :photos
end
project/photo.rb
class Project::Photo < ActiveRecord::Base
belongs_to :project
attachment :file
attr_accessible :name, :address, :created_at, :project_id, :file
before_create :debugging_create
end
config/initializers/refile.rb
require "refile/s3"
aws = {
access_key_id: "xyz",
secret_access_key: "abc",
region: "sa-east-1",
bucket: "my-bucket",
}
Refile.cache = Refile::S3.new(prefix: "cache", **aws)
Refile.store = Refile::S3.new(prefix: "store", **aws)
Output from Refile.backends [Image 1]
Params on file upload looks like this for photos_files [Image 2]
Issues:
Upvotes: 2
Views: 267