Skip to content

Commit

Permalink
Allow download of binary artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCoB1123 committed Jul 21, 2017
1 parent 5165a33 commit 316f6ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
17 changes: 11 additions & 6 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,20 @@ type Build struct {
}

type ArtifactCollection struct {
Count int `json:"count"`
Files []Artifact `json:"file"`
Count int `json:"count"`
Files []*Artifact `json:"file"`
}

type Artifact struct {
Size int `json:"size"`
ModificationTime string `json:"modificationTime"`
Name string `json:"name"`
HREF string `json:"href"`
Size int `json:"size"`
ModificationTime string `json:"modificationTime"`
Name string `json:"name"`
HREF string `json:"href"`
Content *ArtifactContent `json:"content"`
}

type ArtifactContent struct {
HREF string `json:"href"`
}

type oneProperty struct {
Expand Down
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ func (c *Client) GetArtifacts(build *Build) (ArtifactCollection, error) {
return artifacts, err
}

func (c *Client) GetArtifact(artifact *Artifact) (io.Reader, error) {
authURL := fmt.Sprintf("https://%s%s", c.host, artifact.HREF)
func (c *Client) GetArtifact(artifact *ArtifactContent) (io.Reader, error) {
authURL := c.addProtocol(artifact.HREF)

fmt.Printf("Sending request to %s\n", authURL)

var body io.Reader

req, _ := http.NewRequest(method, authURL, body)
req, _ := http.NewRequest("GET", authURL, body)
req.SetBasicAuth(c.username, c.password)
req.Header.Add("Accept", "application/json")

Expand Down

0 comments on commit 316f6ff

Please sign in to comment.