| 114 | } |
| 115 | |
| 116 | func (c Client) DownloadAsset(ctx context.Context, asset ReleaseAsset) ([]byte, error) { |
| 117 | downloadURL := strings.TrimSpace(asset.BrowserDownloadURL) |
| 118 | apiURL := strings.TrimSpace(asset.APIURL) |
| 119 | if downloadURL == "" || c.releaseAssetAPIAuthenticated(apiURL) { |
| 120 | if apiURL != "" { |
| 121 | downloadURL = apiURL |
| 122 | } |
| 123 | } |
| 124 | if downloadURL == "" { |
| 125 | return nil, fmt.Errorf("asset %q missing download url", asset.Name) |
| 126 | } |
| 127 | return c.get(ctx, downloadURL, "application/octet-stream", RequestKindArtifact, 0) |
| 128 | } |
| 129 | |
| 130 | func (c Client) releaseAssetAPIAuthenticated(apiURL string) bool { |
| 131 | apiURL = strings.TrimSpace(apiURL) |