Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
95acf3b8
Commit
95acf3b8
authored
Mar 30, 2016
by
Tute Costa
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2093 from gatherdigital/dynamic-fog-directory
Bugfix: Dynamic fog directory
parents
0ae039d2
84a5d41c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
+13
-6
NEWS
+2
-0
lib/paperclip/storage/fog.rb
+8
-6
spec/paperclip/storage/fog_spec.rb
+3
-0
No files found.
NEWS
View file @
95acf3b8
* Bugfix: Dynamic fog directory option is now respected
5.0.0.beta1
* Drop support to end-of-life'd ruby 2.0.
...
...
lib/paperclip/storage/fog.rb
View file @
95acf3b8
...
...
@@ -195,10 +195,10 @@ module Paperclip
end
def
host_name_for_directory
if
@options
[
:fog_directory
]
.
to_s
=~
Fog
::
AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
"
#{
@options
[
:fog_directory
]
}
.s3.amazonaws.com"
if
directory_name
.
to_s
=~
Fog
::
AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
"
#{
directory_name
}
.s3.amazonaws.com"
else
"s3.amazonaws.com/
#{
@options
[
:fog_directory
]
}
"
"s3.amazonaws.com/
#{
directory_name
}
"
end
end
...
...
@@ -224,13 +224,15 @@ module Paperclip
end
def
directory
dir
=
if
@options
[
:fog_directory
].
respond_to?
(
:call
)
@directory
||=
connection
.
directories
.
new
(
key:
directory_name
)
end
def
directory_name
if
@options
[
:fog_directory
].
respond_to?
(
:call
)
@options
[
:fog_directory
].
call
(
self
)
else
@options
[
:fog_directory
]
end
@directory
||=
connection
.
directories
.
new
(
:key
=>
dir
)
end
def
scheme
...
...
spec/paperclip/storage/fog_spec.rb
View file @
95acf3b8
...
...
@@ -418,6 +418,9 @@ describe Paperclip::Storage::Fog do
assert
@connection
.
directories
.
get
(
@dynamic_fog_directory
).
inspect
end
it
"provides an url using dynamic bucket name"
do
assert_match
(
/^https:\/\/dynamicpaperclip.s3.amazonaws.com\/avatars\/5k.png\?\d*$/
,
@dummy
.
avatar
.
url
)
end
end
context
"with a proc for the fog_host evaluating a model method"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment