Wow, I only make blog posts when there is little information / documentation on something and this takes the cake. I’m currently switching from AWS s3 to Google Cloud Storage because it doesn’t support CORS. People have requested it for 3 years and I don’t think it’ll ever be added.
So I switched to Google Cloud Storage and now I have to modify paperclip to upload assets there. There isn’t much documentation on this, so I had to go around searching for hours. I’m going to save you lots of headache, just copy what I wrote below:
options = {}
options[:path] = attachment_path
options[:storage] = :fog
options[:url] = CONFIG['cdn'] #example: assets.blah.com
options[:fog_credentials] = {
:provider=>'Google',
:google_storage_access_key_id=>CONFIG['GOOGLE_KEY'], #example: GOOGNSFE234C4f
:google_storage_secret_access_key=>CONFIG['GOOGLE_SECRET'] #example: AERG4234D43DFg4234DVDF5423sDCSDC
}
options[:fog_public] = true #this must be set to true or ALL assets will be private by DEFAULT
options[:fog_host] = CONFIG['HOST'] #example: http://assets.blah.com.commondatastorage.googleapis.com This can be changed to CDN
options[:fog_directory] =CONFIG['BUCKET'] #example: assets.blah.com
For the longest time all assets were being made private on Google Cloud Storage. I even changed the default ACL setting but no luck! This was a huge pain. Eventually I noticed the :fog_public wasn’t defaulting to true. So make sure :fog_public is always set to true!