dynamic storage path for saving to other folder on S3. more heroku friendly
This commit is contained in:
parent
666750a72a
commit
972dfbe25e
|
@ -22,7 +22,7 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
# This is a sensible default for uploaders that are meant to be mounted:
|
# This is a sensible default for uploaders that are meant to be mounted:
|
||||||
def store_dir
|
def store_dir
|
||||||
#{}"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
#{}"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||||
"uploads/files/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "files/#{model.album.path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Provide a default URL as a default if there hasn't been a file uploaded
|
# Provide a default URL as a default if there hasn't been a file uploaded
|
||||||
|
@ -41,25 +41,25 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
version :collection do
|
version :collection do
|
||||||
process :resize_to_fill => [200, 200]
|
process :resize_to_fill => [200, 200]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :album do
|
version :album do
|
||||||
process :resize_to_fill => [100, 100]
|
process :resize_to_fill => [100, 100]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :preview do
|
version :preview do
|
||||||
process :resize_to_fit => [210, 210]
|
process :resize_to_fit => [210, 210]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :single do
|
version :single do
|
||||||
process :resize_to_limit => [950, 950]
|
process :resize_to_limit => [950, 950]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
ENV['STORAGE_PATH'] = "uploads" if ENV['STORAGE_PATH'].nil?
|
||||||
#ENV['PRIVATE'] = 'true'
|
#ENV['PRIVATE'] = 'true'
|
||||||
#ENV['TITLE'] = 'photo'
|
#ENV['TITLE'] = 'photo'
|
||||||
#ENV['HEROKU'] = 'true'
|
#ENV['HEROKU'] = 'true'
|
||||||
|
|
|
@ -2,4 +2,4 @@ CarrierWave.configure do |config|
|
||||||
config.s3_access_key_id = ENV['S3_KEY']
|
config.s3_access_key_id = ENV['S3_KEY']
|
||||||
config.s3_secret_access_key = ENV['S3_SECRET']
|
config.s3_secret_access_key = ENV['S3_SECRET']
|
||||||
config.s3_bucket = ENV['S3_BUCKET']
|
config.s3_bucket = ENV['S3_BUCKET']
|
||||||
end
|
end
|
Loading…
Reference in a new issue