Move image upload to S3

This commit is contained in:
Pranav Raj Sreepuram
2019-08-18 01:53:55 +05:30
parent 2b6c7a4025
commit e743abd867
7 changed files with 82 additions and 60 deletions

View File

@@ -1,20 +1,31 @@
require 'carrierwave/storage/fog'
CarrierWave.configure do |config|
config.storage = :fog
config.fog_provider = 'fog/aws' # required
config.storage = :aws
config.aws_bucket = ENV['S3_BUCKET_NAME']
config.aws_acl = 'authenticated-read'
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: 'IAHIHAUVZKNOVTFZGWVT', # required
aws_secret_access_key: 'TNah2bj4p7o5pKbFIqeVAma32pnnXER1r5m7LZvXXFM', # required
region: 'sfo2', # required
endpoint: 'https://sfo2.digitaloceanspaces.com' # required
}
# Optionally define an asset host for configurations that are fronted by a
# content host, such as CloudFront.
#config.asset_host = 'http://example.com'
config.storage = :fog
config.fog_directory = 'chatwoot' # required
# config.fog_public = false # optional, defaults to true
config.asset_host = "https://chatwoot.sfo2.digitaloceanspaces.com"
config.fog_attributes = { 'Cache-Control' => 'max-age=315576000' } # optional, defaults to {}
# The maximum period for authenticated_urls is only 7 days.
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
# Set custom options such as cache control to leverage browser caching
config.aws_attributes = {
expires: 1.week.from_now.httpdate,
cache_control: 'max-age=604800'
}
config.aws_credentials = {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION'] # Required
}
# Optional: Signing of download urls, e.g. for serving private content through
# CloudFront. Be sure you have the `cloudfront-signer` gem installed and
# configured:
# config.aws_signer = -> (unsigned_url, options) do
# Aws::CF::Signer.sign_url(unsigned_url, options)
# end
end