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
Léo-Paul Géneau
gitlab-ce
Commits
7f1adc3d
Commit
7f1adc3d
authored
Feb 20, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix URL to uploaded file.
parent
218283b3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
6 deletions
+9
-6
app/controllers/projects/uploads_controller.rb
app/controllers/projects/uploads_controller.rb
+1
-1
app/services/projects/upload_service.rb
app/services/projects/upload_service.rb
+1
-2
app/uploaders/file_uploader.rb
app/uploaders/file_uploader.rb
+4
-0
config/routes.rb
config/routes.rb
+3
-3
No files found.
app/controllers/projects/uploads_controller.rb
View file @
7f1adc3d
...
...
@@ -4,7 +4,7 @@ class Projects::UploadsController < Projects::ApplicationController
before_filter
:project
def
create
link_to_file
=
::
Projects
::
UploadService
.
new
(
repository
,
params
[
:file
]).
link_to_file
=
::
Projects
::
UploadService
.
new
(
project
,
params
[
:file
]).
execute
respond_to
do
|
format
|
...
...
app/services/projects/upload_service.rb
View file @
7f1adc3d
module
Projects
class
UploadService
<
BaseService
include
Rails
.
application
.
routes
.
url_helpers
def
initialize
(
project
,
file
)
@project
,
@file
=
project
,
file
end
...
...
@@ -15,7 +14,7 @@ module Projects
{
'alt'
=>
filename
,
'url'
=>
project_upload_url
(
@project
,
secret:
uploader
.
secret
,
filename:
uploader
.
file
.
filename
)
,
'url'
=>
uploader
.
secure_url
,
'is_image'
=>
uploader
.
image?
}
end
...
...
app/uploaders/file_uploader.rb
View file @
7f1adc3d
...
...
@@ -25,6 +25,10 @@ class FileUploader < CarrierWave::Uploader::Base
SecureRandom
.
hex
end
def
secure_url
File
.
join
(
Gitlab
.
config
.
gitlab
.
url
,
@project
.
path_with_namespace
,
"uploads"
,
@secret
,
file
.
filename
)
end
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
...
...
config/routes.rb
View file @
7f1adc3d
...
...
@@ -79,8 +79,8 @@ Gitlab::Application.routes.draw do
constraints:
{
model:
/note|user|group|project/
,
mounted_as:
/avatar|attachment/
,
filename:
/.+/
}
# Project markdown uploads
get
":id/:secret/:filename"
,
to:
"projects/uploads#show"
,
constraints:
{
id:
/[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/
,
filename:
/.+/
}
get
":
project_
id/:secret/:filename"
,
to:
"projects/uploads#show"
,
constraints:
{
project_
id:
/[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/
,
filename:
/.+/
}
end
#
...
...
@@ -264,7 +264,7 @@ Gitlab::Application.routes.draw do
resources
:uploads
,
only:
[
:create
]
do
collection
do
get
":secret/:filename"
,
action: :show
,
constraints:
{
filename:
/.+/
}
get
":secret/:filename"
,
action: :show
,
as: :show
,
constraints:
{
filename:
/.+/
}
end
end
...
...
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