Skip to content

Commit

Permalink
trying to get public assets served by cdn and private not
Browse files Browse the repository at this point in the history
  • Loading branch information
yongfook committed Sep 26, 2018
1 parent 2d5e425 commit d020bad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 9 additions & 2 deletions app/models/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ class Product < ApplicationRecord
validates :price_cents, numericality: { greater_than: 0 }
monetize :price_cents
has_many :payments
has_attached_file :image, styles: { large: "1000x1000>", medium: "300x300>", thumb: "100x100>" }, :s3_permissions => { :original => "public-read" }
has_attached_file :file, :s3_headers => {"Content-Disposition" => "attachment"}
has_attached_file :image,
styles: { large: "1000x1000>", medium: "300x300>", thumb: "100x100>" },
:s3_permissions => { :original => "public-read" },
:url => ':s3_alias_url',
:s3_host_alias => ENV['cdn_host_s3_bucket'],
:path => "images/:class/:id.:style.:extension"
has_attached_file :file,
:s3_headers => {"Content-Disposition" => "attachment"},
:path => "files/:class/:id.:style.:extension"
validates_attachment_presence :file
validates_attachment_presence :image
validates_attachment_file_name :file, :matches => [/zip\Z/, /pdf\Z/]
Expand Down
2 changes: 0 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class Application < Rails::Application
config.paperclip_defaults = {
storage: :s3,
s3_permissions: 'private',
url: ':s3_alias_url',
s3_region: ENV['AWS_REGION'],
s3_host_alias: ENV['cdn_host_s3_bucket'],
s3_credentials: {
bucket: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
Expand Down

0 comments on commit d020bad

Please sign in to comment.