Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
352445b2
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
352445b2
编写于
12月 06, 2019
作者:
G
Gannon McGibbon
提交者:
GitHub
12月 06, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #37904 from peterzhu2118/as-remove-query-params
Remove unused query params in DiskService
上级
8cf3f9ad
2e150929
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
14 addition
and
9 deletion
+14
-9
activestorage/CHANGELOG.md
activestorage/CHANGELOG.md
+4
-0
activestorage/lib/active_storage/service/disk_service.rb
activestorage/lib/active_storage/service/disk_service.rb
+0
-2
activestorage/test/controllers/representations_controller_test.rb
...orage/test/controllers/representations_controller_test.rb
+6
-2
activestorage/test/models/blob_test.rb
activestorage/test/models/blob_test.rb
+2
-3
activestorage/test/service/disk_public_service_test.rb
activestorage/test/service/disk_public_service_test.rb
+1
-1
activestorage/test/service/disk_service_test.rb
activestorage/test/service/disk_service_test.rb
+1
-1
未找到文件。
activestorage/CHANGELOG.md
浏览文件 @
352445b2
*
Remove unused
`disposition`
and
`content_type`
query parameters for
`DiskService`
.
*Peter Zhu*
*
Use
`DiskController`
for both public and private files.
*
Use
`DiskController`
for both public and private files.
`DiskController` is able to handle multiple services by adding a
`DiskController` is able to handle multiple services by adding a
...
...
activestorage/lib/active_storage/service/disk_service.rb
浏览文件 @
352445b2
...
@@ -130,8 +130,6 @@ def generate_url(key, expires_in:, filename:, content_type:, disposition:)
...
@@ -130,8 +130,6 @@ def generate_url(key, expires_in:, filename:, content_type:, disposition:)
protocol:
current_uri
.
scheme
,
protocol:
current_uri
.
scheme
,
host:
current_uri
.
host
,
host:
current_uri
.
host
,
port:
current_uri
.
port
,
port:
current_uri
.
port
,
disposition:
content_disposition
,
content_type:
content_type
,
filename:
filename
filename:
filename
)
)
end
end
...
...
activestorage/test/controllers/representations_controller_test.rb
浏览文件 @
352445b2
...
@@ -14,7 +14,9 @@ class ActiveStorage::RepresentationsControllerWithVariantsTest < ActionDispatch:
...
@@ -14,7 +14,9 @@ class ActiveStorage::RepresentationsControllerWithVariantsTest < ActionDispatch:
signed_blob_id:
@blob
.
signed_id
,
signed_blob_id:
@blob
.
signed_id
,
variation_key:
ActiveStorage
::
Variation
.
encode
(
resize:
"100x100"
))
variation_key:
ActiveStorage
::
Variation
.
encode
(
resize:
"100x100"
))
assert_redirected_to
(
/racecar\.jpg\?.*disposition=inline/
)
assert_redirected_to
(
/racecar\.jpg/
)
follow_redirect!
assert_match
(
/^inline/
,
response
.
headers
[
"Content-Disposition"
])
image
=
read_image
(
@blob
.
variant
(
resize:
"100x100"
))
image
=
read_image
(
@blob
.
variant
(
resize:
"100x100"
))
assert_equal
100
,
image
.
width
assert_equal
100
,
image
.
width
...
@@ -43,7 +45,9 @@ class ActiveStorage::RepresentationsControllerWithPreviewsTest < ActionDispatch:
...
@@ -43,7 +45,9 @@ class ActiveStorage::RepresentationsControllerWithPreviewsTest < ActionDispatch:
variation_key:
ActiveStorage
::
Variation
.
encode
(
resize:
"100x100"
))
variation_key:
ActiveStorage
::
Variation
.
encode
(
resize:
"100x100"
))
assert_predicate
@blob
.
preview_image
,
:attached?
assert_predicate
@blob
.
preview_image
,
:attached?
assert_redirected_to
(
/report\.png\?.*disposition=inline/
)
assert_redirected_to
(
/report\.png/
)
follow_redirect!
assert_match
(
/^inline/
,
response
.
headers
[
"Content-Disposition"
])
image
=
read_image
(
@blob
.
preview_image
.
variant
(
resize:
"100x100"
))
image
=
read_image
(
@blob
.
preview_image
.
variant
(
resize:
"100x100"
))
assert_equal
77
,
image
.
width
assert_equal
77
,
image
.
width
...
...
activestorage/test/models/blob_test.rb
浏览文件 @
352445b2
...
@@ -265,9 +265,8 @@ def expected_url_for(blob, disposition: :attachment, filename: nil, content_type
...
@@ -265,9 +265,8 @@ def expected_url_for(blob, disposition: :attachment, filename: nil, content_type
filename
||=
blob
.
filename
filename
||=
blob
.
filename
content_type
||=
blob
.
content_type
content_type
||=
blob
.
content_type
query
=
{
disposition:
ActionDispatch
::
Http
::
ContentDisposition
.
format
(
disposition:
disposition
,
filename:
filename
.
sanitized
),
content_type:
content_type
}
key_params
=
{
key:
blob
.
key
,
disposition:
ActionDispatch
::
Http
::
ContentDisposition
.
format
(
disposition:
disposition
,
filename:
filename
.
sanitized
),
content_type:
content_type
,
service_name:
service_name
}
key_params
=
{
key:
blob
.
key
}.
merge
(
query
).
merge
(
service_name:
service_name
)
"https://example.com/rails/active_storage/disk/
#{
ActiveStorage
.
verifier
.
generate
(
key_params
,
expires_in:
5
.
minutes
,
purpose: :blob_key
)
}
/
#{
filename
}
?
#{
query
.
to_param
}
"
"https://example.com/rails/active_storage/disk/
#{
ActiveStorage
.
verifier
.
generate
(
key_params
,
expires_in:
5
.
minutes
,
purpose: :blob_key
)
}
/
#{
filename
}
"
end
end
end
end
activestorage/test/service/disk_public_service_test.rb
浏览文件 @
352445b2
...
@@ -14,6 +14,6 @@ class ActiveStorage::Service::DiskPublicServiceTest < ActiveSupport::TestCase
...
@@ -14,6 +14,6 @@ class ActiveStorage::Service::DiskPublicServiceTest < ActiveSupport::TestCase
test
"public URL generation"
do
test
"public URL generation"
do
url
=
@service
.
url
(
@key
,
disposition: :inline
,
filename:
ActiveStorage
::
Filename
.
new
(
"avatar.png"
),
content_type:
"image/png"
)
url
=
@service
.
url
(
@key
,
disposition: :inline
,
filename:
ActiveStorage
::
Filename
.
new
(
"avatar.png"
),
content_type:
"image/png"
)
assert_match
(
/^https:\/\/example.com\/rails\/active_storage\/disk\/.*\/avatar\.png
\?content_type=image%2Fpng&disposition=inline.*
/
,
url
)
assert_match
(
/^https:\/\/example.com\/rails\/active_storage\/disk\/.*\/avatar\.png/
,
url
)
end
end
end
end
activestorage/test/service/disk_service_test.rb
浏览文件 @
352445b2
...
@@ -16,7 +16,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
...
@@ -16,7 +16,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
original_url_options
=
Rails
.
application
.
routes
.
default_url_options
.
dup
original_url_options
=
Rails
.
application
.
routes
.
default_url_options
.
dup
Rails
.
application
.
routes
.
default_url_options
.
merge!
(
protocol:
"http"
,
host:
"test.example.com"
,
port:
3001
)
Rails
.
application
.
routes
.
default_url_options
.
merge!
(
protocol:
"http"
,
host:
"test.example.com"
,
port:
3001
)
begin
begin
assert_match
(
/^https:\/\/example.com\/rails\/active_storage\/disk\/.*\/avatar\.png
\?content_type=image%2Fpng&disposition=inline
/
,
assert_match
(
/^https:\/\/example.com\/rails\/active_storage\/disk\/.*\/avatar\.png
$
/
,
@service
.
url
(
@key
,
expires_in:
5
.
minutes
,
disposition: :inline
,
filename:
ActiveStorage
::
Filename
.
new
(
"avatar.png"
),
content_type:
"image/png"
))
@service
.
url
(
@key
,
expires_in:
5
.
minutes
,
disposition: :inline
,
filename:
ActiveStorage
::
Filename
.
new
(
"avatar.png"
),
content_type:
"image/png"
))
ensure
ensure
Rails
.
application
.
routes
.
default_url_options
=
original_url_options
Rails
.
application
.
routes
.
default_url_options
=
original_url_options
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录