Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
2e150929
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,发现更多精彩内容 >>
提交
2e150929
编写于
12月 06, 2019
作者:
P
Peter Zhu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove query params in DiskService
上级
8cf3f9ad
变更
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
浏览文件 @
2e150929
*
Remove unused
`disposition`
and
`content_type`
query parameters for
`DiskService`
.
*Peter Zhu*
*
Use
`DiskController`
for both public and private files.
`DiskController` is able to handle multiple services by adding a
...
...
activestorage/lib/active_storage/service/disk_service.rb
浏览文件 @
2e150929
...
...
@@ -130,8 +130,6 @@ def generate_url(key, expires_in:, filename:, content_type:, disposition:)
protocol:
current_uri
.
scheme
,
host:
current_uri
.
host
,
port:
current_uri
.
port
,
disposition:
content_disposition
,
content_type:
content_type
,
filename:
filename
)
end
...
...
activestorage/test/controllers/representations_controller_test.rb
浏览文件 @
2e150929
...
...
@@ -14,7 +14,9 @@ class ActiveStorage::RepresentationsControllerWithVariantsTest < ActionDispatch:
signed_blob_id:
@blob
.
signed_id
,
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"
))
assert_equal
100
,
image
.
width
...
...
@@ -43,7 +45,9 @@ class ActiveStorage::RepresentationsControllerWithPreviewsTest < ActionDispatch:
variation_key:
ActiveStorage
::
Variation
.
encode
(
resize:
"100x100"
))
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"
))
assert_equal
77
,
image
.
width
...
...
activestorage/test/models/blob_test.rb
浏览文件 @
2e150929
...
...
@@ -265,9 +265,8 @@ def expected_url_for(blob, disposition: :attachment, filename: nil, content_type
filename
||=
blob
.
filename
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
}.
merge
(
query
).
merge
(
service_name:
service_name
)
key_params
=
{
key:
blob
.
key
,
disposition:
ActionDispatch
::
Http
::
ContentDisposition
.
format
(
disposition:
disposition
,
filename:
filename
.
sanitized
),
content_type:
content_type
,
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
activestorage/test/service/disk_public_service_test.rb
浏览文件 @
2e150929
...
...
@@ -14,6 +14,6 @@ class ActiveStorage::Service::DiskPublicServiceTest < ActiveSupport::TestCase
test
"public URL generation"
do
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
activestorage/test/service/disk_service_test.rb
浏览文件 @
2e150929
...
...
@@ -16,7 +16,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
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
)
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"
))
ensure
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录