greyblake/blogo

Upload images to AWS

stevendelarwelle opened this issue · 4 comments

I would love to be able to upload images to AWS with paperclip. Is there anybody working on this feature?

Not yet

Can you please add AWS feature because if we use it on heroku we can't store image on system folder, heroku doesn't support local storage for image

Or let us know AWS setting direction

Finally I am able to store image on s3 storage

I describe the process to add s3 storage using carrier wave gem

gem 'carrierwave'
gem 'carrierwave-aws'

set s3 credentail in config/initializers/carrierwave.rb file

in the lib folder I loaded carrierwave file

lib/blogo/blogo.rb and add this line
require 'carrierwave'

create image table with attribute 'image'

changes in images_controller.rb file

def create
  upload_io = params[:upload]
  @image = Blogo::Image.new(image_name: upload_io)
  @image.save
  # image_name = upload_io.original_filename
  # file_path = Rails.root.join('public', image_directory, image_name)

  # if File.exist?(file_path)
  #   @error = I18n.translate('blogo.admin.image_already_exists', image_name: image_name)
  # else
  #   dir = File.dirname(file_path)
  #   FileUtils.mkdir_p(dir) unless File.exist?(dir)
  #   File.binwrite(file_path, upload_io.read)
  # end

  @image_path = @image.image_name.url
end

@greyblake Can you please look into this fix if it's fine? It worked for me