Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
a699ebdb
Commit
a699ebdb
authored
Feb 11, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle attahcment with send_file
parent
ab0cfc00
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
2 deletions
+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
No files found.
app/controllers/files_controller.rb
0 → 100644
View file @
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
View file @
a699ebdb
...
@@ -19,4 +19,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base
...
@@ -19,4 +19,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base
rescue
rescue
false
false
end
end
def
secure_url
"/files/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
model
.
id
}
/
#{
file
.
filename
}
"
end
end
end
app/views/events/event/_note.html.haml
View file @
a699ebdb
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
=
markdown
truncate
(
event
.
target
.
note
,
length:
70
)
=
markdown
truncate
(
event
.
target
.
note
,
length:
70
)
-
note
=
event
.
target
-
note
=
event
.
target
-
if
note
.
attachment
.
url
-
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?
-
if
note
.
attachment
.
image?
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
-
else
-
else
...
...
app/views/notes/_note.html.haml
View file @
a699ebdb
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
-
if
note
.
attachment
.
image?
-
if
note
.
attachment
.
image?
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
.attachment.pull-right
.attachment.pull-right
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
do
=
link_to
note
.
attachment
.
secure_
url
,
target:
"_blank"
do
%i
.icon-paper-clip
%i
.icon-paper-clip
=
note
.
attachment_identifier
=
note
.
attachment_identifier
.clear
.clear
config/routes.rb
View file @
a699ebdb
...
@@ -45,6 +45,11 @@ Gitlab::Application.routes.draw do
...
@@ -45,6 +45,11 @@ Gitlab::Application.routes.draw do
root
to:
"projects#index"
root
to:
"projects#index"
end
end
#
# Attachments serving
#
get
'files/:type/:id/:filename'
=>
'files#download'
,
constraints:
{
id:
/\d+/
,
type:
/[a-z]+/
,
filename:
/[a-zA-Z.0-9_\-\+]+/
}
#
#
# Admin Area
# Admin Area
#
#
...
...
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