How to use Rails and Paperclip to store photos on Google Cloud Storage?

427 views
Skip to first unread message

user984621 via StackOverflow

unread,
Jul 31, 2014, 8:23:38 AM7/31/14
to google-appengin...@googlegroups.com

Until now, I have been using Amazon S3 for storing users' files.

All I what has been needed here was to: - specify Amazon S3 credentials to the bucket - add 'aws-sdk' gem to the Gemfile - and in the model:

  has_attached_file :avatar, 
                    :styles => { :big => "100x100#", :thumb => "25x25#" },
                    :storage => :s3,
                    :s3_credentials => "#{Rails.root}/config/s3.yml",
                    :path => ":rails_root/public/users/:id/:style/:basename.:extension",
                    :url => "/users/:id/:style/:basename.:extension"

To set the Amazon S3 adapter. That was all.

But how to set up Google cloud engine? So far I found only the fog gem , which I could use.

However, how should I configure the model to automatically store all uploaded files on Google servers?



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/25058751/how-to-use-rails-and-paperclip-to-store-photos-on-google-cloud-storage

user984621 via StackOverflow

unread,
Jul 31, 2014, 9:23:35 AM7/31/14
to google-appengin...@googlegroups.com

Ok, so I made it work this way:

Gemfile:

gem 'fog'

config/gce.yml:

development:
  provider: Google
  google_storage_access_key_id: XXX
  google_storage_secret_access_key: XXX

model:

  has_attached_file :avatar, 
                    :styles => { :big => "100x100#", :thumb => "25x25#" },
                    :storage => :fog,
                    :fog_credentials => "#{Rails.root}/config/gce.yml",
                    :fog_directory => "your bucket name",
                    :path => ":rails_root/public/users/:id/:style/:basename.:extension",
                    :url => "/users/:id/:style/:basename.:extension"


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/25058751/how-to-use-rails-and-paperclip-to-store-photos-on-google-cloud-storage/25059961#25059961
Reply all
Reply to author
Forward
0 new messages