Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a699ebdb
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a699ebdb
编写于
2月 11, 2013
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle attahcment with send_file
上级
ab0cfc00
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
19 addition
and
2 deletion
+19
-2
app/controllers/files_controller.rb
app/controllers/files_controller.rb
+8
-0
app/uploaders/attachment_uploader.rb
app/uploaders/attachment_uploader.rb
+4
-0
app/views/events/event/_note.html.haml
app/views/events/event/_note.html.haml
+1
-1
app/views/notes/_note.html.haml
app/views/notes/_note.html.haml
+1
-1
config/routes.rb
config/routes.rb
+5
-0
未找到文件。
app/controllers/files_controller.rb
0 → 100644
浏览文件 @
a699ebdb
class
FilesController
<
ApplicationController
def
download
uploader
=
Note
.
find
(
params
[
:id
]).
attachment
uploader
.
retrieve_from_store!
(
params
[
:filename
])
send_file
uploader
.
file
.
path
,
disposition:
'attachment'
end
end
app/uploaders/attachment_uploader.rb
浏览文件 @
a699ebdb
...
...
@@ -19,4 +19,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base
rescue
false
end
def
secure_url
"/files/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
model
.
id
}
/
#{
file
.
filename
}
"
end
end
app/views/events/event/_note.html.haml
浏览文件 @
a699ebdb
...
...
@@ -26,7 +26,7 @@
=
markdown
truncate
(
event
.
target
.
note
,
length:
70
)
-
note
=
event
.
target
-
if
note
.
attachment
.
url
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
=
link_to
note
.
attachment
.
secure_
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
-
if
note
.
attachment
.
image?
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
-
else
...
...
app/views/notes/_note.html.haml
浏览文件 @
a699ebdb
...
...
@@ -31,7 +31,7 @@
-
if
note
.
attachment
.
image?
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
.attachment.pull-right
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
do
=
link_to
note
.
attachment
.
secure_
url
,
target:
"_blank"
do
%i
.icon-paper-clip
=
note
.
attachment_identifier
.clear
config/routes.rb
浏览文件 @
a699ebdb
...
...
@@ -45,6 +45,11 @@ Gitlab::Application.routes.draw do
root
to:
"projects#index"
end
#
# Attachments serving
#
get
'files/:type/:id/:filename'
=>
'files#download'
,
constraints:
{
id:
/\d+/
,
type:
/[a-z]+/
,
filename:
/[a-zA-Z.0-9_\-\+]+/
}
#
# Admin Area
#
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录