blogo icon indicating copy to clipboard operation
blogo copied to clipboard

Upload images to AWS

Open stevendelarwelle opened this issue 8 years ago • 4 comments

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

stevendelarwelle avatar Apr 04 '16 13:04 stevendelarwelle

Not yet

greyblake avatar Apr 06 '16 11:04 greyblake

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

shashi-we avatar Aug 31 '16 08:08 shashi-we

Or let us know AWS setting direction

shashi-we avatar Aug 31 '16 08:08 shashi-we

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

shashi-we avatar Sep 26 '16 14:09 shashi-we