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
5b22af36
Commit
5b22af36
authored
Aug 19, 2014
by
Michael Baudino
Committed by
Jon Yurek
Aug 29, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Honor fog_credentials[:scheme] option
parent
3b66d309
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletions
+34
-1
lib/paperclip/storage/fog.rb
+6
-1
spec/paperclip/storage/fog_spec.rb
+28
-0
No files found.
lib/paperclip/storage/fog.rb
View file @
5b22af36
...
...
@@ -14,6 +14,7 @@ module Paperclip
# aws_secret_access_key: '<your aws_secret_access_key>'
# provider: 'AWS'
# region: 'eu-west-1'
# scheme: 'https'
# * +fog_directory+: This is the name of the S3 bucket that will
# store your files. Remember that the bucket must be unique across
# all of Amazon S3. If the bucket does not exist, Paperclip will
...
...
@@ -131,7 +132,7 @@ module Paperclip
"
#{
dynamic_fog_host_for_style
(
style
)
}
/
#{
path
(
style
)
}
"
else
if
fog_credentials
[
:provider
]
==
'AWS'
"
https
://
#{
host_name_for_directory
}
/
#{
path
(
style
)
}
"
"
#{
scheme
}
://
#{
host_name_for_directory
}
/
#{
path
(
style
)
}
"
else
directory
.
files
.
new
(
:key
=>
path
(
style
)).
public_url
end
...
...
@@ -225,6 +226,10 @@ module Paperclip
@directory
||=
connection
.
directories
.
new
(
:key
=>
dir
)
end
def
scheme
@scheme
||=
fog_credentials
[
:scheme
]
||
'https'
end
end
end
end
spec/paperclip/storage/fog_spec.rb
View file @
5b22af36
...
...
@@ -308,6 +308,34 @@ describe Paperclip::Storage::Fog do
end
end
context
"with scheme set"
do
before
do
rebuild_model
(
@options
.
merge
(
:fog_credentials
=>
@credentials
.
merge
(
:scheme
=>
'http'
)))
@file
=
File
.
new
(
fixture_file
(
'5k.png'
),
'rb'
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
@dummy
.
save
end
it
"honors the scheme in public url"
do
assert_match
(
/^http:\/\//
,
@dummy
.
avatar
.
url
)
end
end
context
"with scheme not set"
do
before
do
rebuild_model
(
@options
)
@file
=
File
.
new
(
fixture_file
(
'5k.png'
),
'rb'
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
@dummy
.
save
end
it
"provides HTTPS public url"
do
assert_match
(
/^https:\/\//
,
@dummy
.
avatar
.
url
)
end
end
context
"with a valid bucket name for a subdomain"
do
it
"provides an url in subdomain style"
do
assert_match
(
/^https:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png/
,
@dummy
.
avatar
.
url
)
...
...
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