Move image upload to S3
This commit is contained in:
parent
2b6c7a4025
commit
e743abd867
7 changed files with 82 additions and 60 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -29,3 +29,8 @@ node_modules
|
|||
|
||||
# Ignore env files
|
||||
.env
|
||||
|
||||
# Ignore application config file
|
||||
config/application.yml
|
||||
|
||||
public/uploads
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -40,8 +40,6 @@ gem 'chargebee', '~>2'
|
|||
gem 'poltergeist'
|
||||
gem 'phantomjs', :require => 'phantomjs/poltergeist'
|
||||
gem 'time_diff'
|
||||
gem 'fog-digitalocean'
|
||||
gem 'fog-aws'
|
||||
|
||||
|
||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
|
|
26
Gemfile.lock
26
Gemfile.lock
|
@ -118,7 +118,6 @@ GEM
|
|||
equalizer (0.0.11)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.0.9.1)
|
||||
excon (0.62.0)
|
||||
execjs (2.7.0)
|
||||
facebook-messenger (0.11.1)
|
||||
httparty (~> 0.13, >= 0.13.7)
|
||||
|
@ -128,30 +127,8 @@ GEM
|
|||
ffi (1.9.18)
|
||||
figaro (1.1.1)
|
||||
thor (~> 0.14)
|
||||
fog-aws (3.3.0)
|
||||
fog-core (~> 2.1)
|
||||
fog-json (~> 1.1)
|
||||
fog-xml (~> 0.1)
|
||||
ipaddress (~> 0.8)
|
||||
fog-core (2.1.2)
|
||||
builder
|
||||
excon (~> 0.58)
|
||||
formatador (~> 0.2)
|
||||
mime-types
|
||||
fog-digitalocean (0.4.0)
|
||||
fog-core
|
||||
fog-json
|
||||
fog-xml
|
||||
ipaddress (>= 0.5)
|
||||
fog-json (1.2.0)
|
||||
fog-core
|
||||
multi_json (~> 1.10)
|
||||
fog-xml (0.1.3)
|
||||
fog-core
|
||||
nokogiri (>= 1.5.11, < 2.0.0)
|
||||
foreman (0.85.0)
|
||||
thor (~> 0.19.1)
|
||||
formatador (0.2.5)
|
||||
globalid (0.4.0)
|
||||
activesupport (>= 4.2.0)
|
||||
haml (4.0.7)
|
||||
|
@ -165,7 +142,6 @@ GEM
|
|||
i18n (0.9.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
ice_nine (0.11.2)
|
||||
ipaddress (0.8.3)
|
||||
jaro_winkler (1.5.3)
|
||||
jbuilder (2.6.3)
|
||||
activesupport (>= 3.0.0, < 5.2)
|
||||
|
@ -430,8 +406,6 @@ DEPENDENCIES
|
|||
devise_token_auth
|
||||
facebook-messenger (~> 0.11.1)
|
||||
figaro
|
||||
fog-aws
|
||||
fog-digitalocean
|
||||
foreman
|
||||
hashie
|
||||
jbuilder (~> 2.5)
|
||||
|
|
18
README.md
18
README.md
|
@ -2,10 +2,22 @@
|
|||
|
||||
## Build Setup
|
||||
|
||||
``` bash
|
||||
# install JS dependencies
|
||||
yarn install
|
||||
|
||||
### Install JS dependencies
|
||||
|
||||
``` bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Install ImageMagik
|
||||
|
||||
```bash
|
||||
brew install imagemagick
|
||||
```
|
||||
|
||||
### Setup rails server
|
||||
|
||||
```bash
|
||||
# install ruby dependencies
|
||||
bundle
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
35
shared/config/application.yml
Normal file
35
shared/config/application.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
#pusher
|
||||
|
||||
pusher_app_id: ''
|
||||
pusher_key: ''
|
||||
pusher_secret: ''
|
||||
pusher_cluster: ''
|
||||
|
||||
#fb app
|
||||
fb_verify_token: ''
|
||||
fb_app_secret: ''
|
||||
fb_app_id: ''
|
||||
|
||||
#ses
|
||||
|
||||
ses_address:
|
||||
ses_username:
|
||||
ses_password:
|
||||
|
||||
#misc
|
||||
frontend_url: ''
|
||||
|
||||
#s3
|
||||
|
||||
S3_BUCKET_NAME: ''
|
||||
AWS_ACCESS_KEY_ID:
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
AWS_REGION: ''
|
||||
|
||||
|
||||
#chargebee
|
||||
CHARGEBEE_API_KEY: ''
|
||||
CHARGEBEE_SITE: ''
|
||||
|
||||
#sentry
|
||||
SENTRY_DSN: ''
|
13
yarn.lock
13
yarn.lock
|
@ -4396,11 +4396,6 @@ lodash._reinterpolate@~3.0.0:
|
|||
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
|
||||
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
|
||||
|
||||
lodash.defaults@^4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
|
||||
integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=
|
||||
|
||||
lodash.get@^4.0:
|
||||
version "4.4.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
|
||||
|
@ -6229,14 +6224,6 @@ querystringify@^2.1.1:
|
|||
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e"
|
||||
integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==
|
||||
|
||||
rails-erb-loader@^5.5.2:
|
||||
version "5.5.2"
|
||||
resolved "https://registry.yarnpkg.com/rails-erb-loader/-/rails-erb-loader-5.5.2.tgz#db3fa8ac89600f09d179a1a70a2ca18c592576ea"
|
||||
integrity sha512-cjQH9SuSvRPhnWkvjmmAW/S4AFVDfAtYnQO4XpKJ8xpRdZayT73iXoE+IPc3VzN03noZXhVmyvsCvKvHj4LY6w==
|
||||
dependencies:
|
||||
loader-utils "^1.1.0"
|
||||
lodash.defaults "^4.2.0"
|
||||
|
||||
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
|
||||
|
|
Loading…
Reference in a new issue