Skip to content

Commit 3f41766

Browse files
committed
paperclip/fog uses secrets
1 parent 632f391 commit 3f41766

File tree

3 files changed

+37
-29
lines changed

3 files changed

+37
-29
lines changed

app/models/concerns/downloadable_file.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module DownloadableFile
33
extend ActiveSupport::Concern
44

55
included do
6-
has_attached_file :file, Settings.paperclip.to_hash.merge(validate_media_type: false)
6+
has_attached_file :file, PaperclipSettings.config.to_hash.merge(validate_media_type: false)
77

88
# TODO: Limit attachment types for safe uploads
99
do_not_validate_attachment_file_type :file
1010
end
1111

1212
def download_url
13-
if fog?
13+
if PaperclipSettings.fog?
1414
# This is a workaround due to a bug or limitation in fog to generate a
1515
# private, expiring URL and have it force a download.
1616
#
@@ -31,10 +31,4 @@ def download_url
3131
end
3232
end
3333

34-
private
35-
36-
def fog?
37-
Settings.paperclip.storage == "fog"
38-
end
39-
4034
end

config/initializers/paperclip.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@
1313
Paperclip.options[:content_type_mappings] = {
1414
xls: "CDF V2 Document, No summary info",
1515
}
16+
17+
class PaperclipSettings
18+
19+
def self.config
20+
secrets = Hash(Rails.application.secrets.paperclip).symbolize_keys
21+
Settings.paperclip.to_hash.merge(secrets)
22+
end
23+
24+
def self.fog?
25+
config[:storage] == "fog"
26+
end
27+
28+
end

config/secrets.yml.template

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
development:
22
secret_key_base: ~
33

4+
# You should change this if you want to be able to access the API
5+
api:
6+
basic_auth_name: <%= SecureRandom.hex %>
7+
basic_auth_password: <%= SecureRandom.hex %>
8+
9+
# You should change this if you want to be able to access the SecureRooms API
10+
secure_rooms_api:
11+
basic_auth_name: <%= SecureRandom.hex %>
12+
basic_auth_password: <%= SecureRandom.hex %>
13+
14+
# Uncomment these lines if you wish to use S3 in your application.
15+
# paperclip:
16+
# storage: fog
17+
# fog_credentials:
18+
# provider: AWS
19+
# aws_access_key_id: Your-Key-Here
20+
# aws_secret_access_key: Your-Key-Here
21+
# fog_directory: Your-Bucket-Name-Here
22+
# fog_public: false
23+
# path: ":class/:attachment/:id_partition/:style/:safe_filename"
24+
25+
426
test:
527
secret_key_base: needs_a_value_for_ci
628

729
production:
830
secret_key_base: ~
931
rollbar: ~
10-
11-
# You should change this if you want to be able to access the API
12-
api:
13-
basic_auth_name: <%= SecureRandom.hex %>
14-
basic_auth_password: <%= SecureRandom.hex %>
15-
16-
# You should change this if you want to be able to access the SecureRooms API
17-
secure_rooms_api:
18-
basic_auth_name: <%= SecureRandom.hex %>
19-
basic_auth_password: <%= SecureRandom.hex %>
20-
21-
# Uncomment these lines if you wish to use S3 in your application.
22-
# paperclip:
23-
# storage: fog
24-
# fog_credentials:
25-
# provider: AWS
26-
# aws_access_key_id: Your-Key-Here
27-
# aws_secret_access_key: Your-Key-Here
28-
# fog_directory: Your-Bucket-Name-Here
29-
# fog_public: false
30-
# path: ":class/:attachment/:id_partition/:style/:safe_filename"

0 commit comments

Comments
 (0)