Init aws support for file storage
This commit is contained in:
parent
cde6b8e4da
commit
23ee8e6257
3 changed files with 37 additions and 0 deletions
2
Gemfile
2
Gemfile
|
@ -57,6 +57,8 @@ gem "haml-rails"
|
|||
|
||||
# Files attachments
|
||||
gem "carrierwave"
|
||||
# for aws storage
|
||||
# gem "fog", "~> 1.3.1"
|
||||
|
||||
# Authorization
|
||||
gem "six"
|
||||
|
|
19
config/aws.yml.example
Normal file
19
config/aws.yml.example
Normal file
|
@ -0,0 +1,19 @@
|
|||
# See https://github.com/jnicklas/carrierwave#using-amazon-s3
|
||||
# for more options
|
||||
production:
|
||||
access_key_id: AKIA1111111111111UA
|
||||
secret_access_key: secret
|
||||
bucket: mygitlab.production.us
|
||||
region: us-east-1
|
||||
|
||||
development:
|
||||
access_key_id: AKIA1111111111111UA
|
||||
secret_access_key: secret
|
||||
bucket: mygitlab.development.us
|
||||
region: us-east-1
|
||||
|
||||
test:
|
||||
access_key_id: AKIA1111111111111UA
|
||||
secret_access_key: secret
|
||||
bucket: mygitlab.test.us
|
||||
region: us-east-1
|
|
@ -1 +1,17 @@
|
|||
CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/
|
||||
|
||||
aws_file = Rails.root.join('config', 'aws.yml')
|
||||
|
||||
if File.exists?(aws_file)
|
||||
AWS_CONFIG = YAML.load(File.read(aws_file))[Rails.env]
|
||||
|
||||
config.fog_credentials = {
|
||||
provider: 'AWS', # required
|
||||
aws_access_key_id: AWS_CONFIG['access_key_id'], # required
|
||||
aws_secret_access_key: AWS_CONFIG['secret_access_key'], # required
|
||||
region: AWS_CONFIG['region'], # optional, defaults to 'us-east-1'
|
||||
}
|
||||
config.fog_directory = AWS_CONFIG['bucket'] # required
|
||||
config.fog_public = false # optional, defaults to true
|
||||
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue