Created
May 7, 2017 01:29
-
-
Save ryuheechul/c42ab12ed96bdf1f1a8767cc3b18cc19 to your computer and use it in GitHub Desktop.
Paperclip + fog + Google Cloud Storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/paperclip.rb | |
if Rails.env.production? | |
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename' | |
Paperclip::Attachment.default_options[:url] = ':gcs_domain_url' | |
Paperclip::Attachment.default_options[:fog_directory] = ENV['GCS_BUCKET_NAME'] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/production.rb | |
config.paperclip_defaults = { | |
storage: :fog, | |
fog_credentials: { | |
provider: 'Google', | |
google_project: ENV['GCS_PROJECT'], | |
google_client_email: ENV['GCS_CLIENT_EMAIL'], | |
google_json_key_string: Base64.decode64(ENV['GCS_SECRET_JSON_KEY_STRING_BASE64']) | |
# Google recommend you to use service account instead of HMAC credentials | |
# You can check other options here -> https://github.com/fog/fog-google#credentials | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment