Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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
1
Merge Requests
1
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
nexedi
gitlab-workhorse
Commits
35482adc
Commit
35482adc
authored
Jan 14, 2016
by
Grzegorz Bizon
Committed by
Kamil Trzcinski
Jan 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change API for artifacts single file download
parent
ceedac04
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
internal/api/api.go
internal/api/api.go
+2
-2
internal/artifacts/artifacts.go
internal/artifacts/artifacts.go
+9
-9
internal/upstream/routes.go
internal/upstream/routes.go
+1
-1
No files found.
internal/api/api.go
View file @
35482adc
...
@@ -60,8 +60,8 @@ type Response struct {
...
@@ -60,8 +60,8 @@ type Response struct {
TempPath
string
TempPath
string
// Archive is the path where the artifacts archive is stored
// Archive is the path where the artifacts archive is stored
Archive
string
`json:"archive"`
Archive
string
`json:"archive"`
//
Path is the filename inside the archive to extracted file
//
Entry is a filename inside the archive point to file that needs to be extracted
Path
string
`json:"path
"`
Entry
string
`json:"entry
"`
}
}
// singleJoiningSlash is taken from reverseproxy.go:NewSingleHostReverseProxy
// singleJoiningSlash is taken from reverseproxy.go:NewSingleHostReverseProxy
...
...
internal/artifacts/artifacts.go
View file @
35482adc
...
@@ -2,17 +2,17 @@ package artifacts
...
@@ -2,17 +2,17 @@ package artifacts
import
(
import
(
"../api"
"../api"
"../upload"
"net/http"
"../helper"
"../helper"
"errors"
"../upload"
"os"
"archive/zip"
"archive/zip"
"encoding/base64"
"encoding/base64"
"strconv"
"errors"
"io"
"mime"
"mime"
"net/http"
"os"
"path/filepath"
"path/filepath"
"
io
"
"
strconv
"
)
)
func
UploadArtifacts
(
myAPI
*
api
.
API
,
h
http
.
Handler
)
http
.
Handler
{
func
UploadArtifacts
(
myAPI
*
api
.
API
,
h
http
.
Handler
)
http
.
Handler
{
...
@@ -29,12 +29,12 @@ func UploadArtifacts(myAPI *api.API, h http.Handler) http.Handler {
...
@@ -29,12 +29,12 @@ func UploadArtifacts(myAPI *api.API, h http.Handler) http.Handler {
// Artifacts downloader doesn't support ranges when downloading a single file
// Artifacts downloader doesn't support ranges when downloading a single file
func
DownloadArtifact
(
myAPI
*
api
.
API
)
http
.
Handler
{
func
DownloadArtifact
(
myAPI
*
api
.
API
)
http
.
Handler
{
return
myAPI
.
PreAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
api
.
Response
)
{
return
myAPI
.
PreAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
api
.
Response
)
{
if
a
.
Archive
==
""
||
a
.
Path
==
""
{
if
a
.
Archive
==
""
||
a
.
Entry
==
""
{
helper
.
Fail500
(
w
,
errors
.
New
(
"DownloadArtifact: Archive or Path is empty"
))
helper
.
Fail500
(
w
,
errors
.
New
(
"DownloadArtifact: Archive or Path is empty"
))
return
return
}
}
fileNameDecoded
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
a
.
Path
)
fileNameDecoded
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
a
.
Entry
)
if
err
!=
nil
{
if
err
!=
nil
{
helper
.
Fail500
(
w
,
err
)
helper
.
Fail500
(
w
,
err
)
return
return
...
@@ -70,7 +70,7 @@ func DownloadArtifact(myAPI *api.API) http.Handler {
...
@@ -70,7 +70,7 @@ func DownloadArtifact(myAPI *api.API) http.Handler {
w
.
Header
()
.
Set
(
"Content-Length"
,
strconv
.
FormatInt
(
int64
(
file
.
UncompressedSize64
),
10
))
w
.
Header
()
.
Set
(
"Content-Length"
,
strconv
.
FormatInt
(
int64
(
file
.
UncompressedSize64
),
10
))
w
.
Header
()
.
Set
(
"Content-Type"
,
contentType
)
w
.
Header
()
.
Set
(
"Content-Type"
,
contentType
)
w
.
Header
()
.
Set
(
"Content-Disposition"
,
"attachment; filename="
+
filepath
.
Base
(
file
.
Name
))
w
.
Header
()
.
Set
(
"Content-Disposition"
,
"attachment; filename="
+
filepath
.
Base
(
file
.
Name
))
reader
,
err
:=
file
.
Open
()
reader
,
err
:=
file
.
Open
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
internal/upstream/routes.go
View file @
35482adc
...
@@ -65,7 +65,7 @@ func (u *Upstream) configureRoutes() {
...
@@ -65,7 +65,7 @@ func (u *Upstream) configureRoutes() {
route
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar.bz2\z`
),
git
.
GetArchive
(
api
)},
route
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar.bz2\z`
),
git
.
GetArchive
(
api
)},
// CI Artifacts
// CI Artifacts
route
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`builds/[0-9]+/file/`
),
contentEncodingHandler
(
artifacts
.
DownloadArtifact
(
api
))},
route
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`builds/[0-9]+/
artifacts/
file/`
),
contentEncodingHandler
(
artifacts
.
DownloadArtifact
(
api
))},
route
{
"POST"
,
regexp
.
MustCompile
(
ciAPIPattern
+
`v1/builds/[0-9]+/artifacts\z`
),
contentEncodingHandler
(
artifacts
.
UploadArtifacts
(
api
,
proxy
))},
route
{
"POST"
,
regexp
.
MustCompile
(
ciAPIPattern
+
`v1/builds/[0-9]+/artifacts\z`
),
contentEncodingHandler
(
artifacts
.
UploadArtifacts
(
api
,
proxy
))},
// Explicitly proxy API requests
// Explicitly proxy API requests
...
...
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