BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7e5deb6a
Commit
7e5deb6a
authored
Dec 21, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'multipart-uploaded-file' into 'master'
Inject ::UploadedFile from Multipart middleware Closes #25888 See merge request !8215
parents
1548f7e0
4ec259fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
multipart.rb
lib/gitlab/middleware/multipart.rb
+6
-2
multipart_spec.rb
spec/lib/gitlab/middleware/multipart_spec.rb
+3
-3
No files found.
lib/gitlab/middleware/multipart.rb
View file @
7e5deb6a
...
...
@@ -42,7 +42,7 @@ module Gitlab
key
,
value
=
parsed_field
.
first
if
value
.
nil?
value
=
File
.
open
(
tmp_path
)
value
=
open_file
(
tmp_path
)
@open_files
<<
value
else
value
=
decorate_params_value
(
value
,
@request
.
params
[
key
],
tmp_path
)
...
...
@@ -68,7 +68,7 @@ module Gitlab
case
path_value
when
nil
value_hash
[
path_key
]
=
File
.
open
(
tmp_path
)
value_hash
[
path_key
]
=
open_file
(
tmp_path
)
@open_files
<<
value_hash
[
path_key
]
value_hash
when
Hash
...
...
@@ -78,6 +78,10 @@ module Gitlab
raise
"unexpected path value:
#{
path_value
.
inspect
}
"
end
end
def
open_file
(
path
)
::
UploadedFile
.
new
(
path
,
File
.
basename
(
path
),
'application/octet-stream'
)
end
end
def
initialize
(
app
)
...
...
spec/lib/gitlab/middleware/multipart_spec.rb
View file @
7e5deb6a
...
...
@@ -12,7 +12,7 @@ describe Gitlab::Middleware::Multipart do
expect
(
app
).
to
receive
(
:call
)
do
|
env
|
file
=
Rack
::
Request
.
new
(
env
).
params
[
'file'
]
expect
(
file
).
to
be_a
(
File
)
expect
(
file
).
to
be_a
(
::
Uploaded
File
)
expect
(
file
.
path
).
to
eq
(
tempfile
.
path
)
end
...
...
@@ -39,7 +39,7 @@ describe Gitlab::Middleware::Multipart do
expect
(
app
).
to
receive
(
:call
)
do
|
env
|
file
=
Rack
::
Request
.
new
(
env
).
params
[
'user'
][
'avatar'
]
expect
(
file
).
to
be_a
(
File
)
expect
(
file
).
to
be_a
(
::
Uploaded
File
)
expect
(
file
.
path
).
to
eq
(
tempfile
.
path
)
end
...
...
@@ -54,7 +54,7 @@ describe Gitlab::Middleware::Multipart do
expect
(
app
).
to
receive
(
:call
)
do
|
env
|
file
=
Rack
::
Request
.
new
(
env
).
params
[
'project'
][
'milestone'
][
'themesong'
]
expect
(
file
).
to
be_a
(
File
)
expect
(
file
).
to
be_a
(
::
Uploaded
File
)
expect
(
file
.
path
).
to
eq
(
tempfile
.
path
)
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