feat: support template bundles as zip archives (#11839)

This commit is contained in:
Marcin Tojek
2024-01-31 14:49:55 +01:00
committed by GitHub
parent b25deaae20
commit 13cbca679e
8 changed files with 248 additions and 18 deletions
+9 -1
View File
@@ -12,6 +12,9 @@ import (
const (
ContentTypeTar = "application/x-tar"
ContentTypeZip = "application/zip"
FormatZip = "zip"
)
// UploadResponse contains the hash to reference the uploaded file.
@@ -38,7 +41,12 @@ func (c *Client) Upload(ctx context.Context, contentType string, rd io.Reader) (
// Download fetches a file by uploaded hash.
func (c *Client) Download(ctx context.Context, id uuid.UUID) ([]byte, string, error) {
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/files/%s", id.String()), nil)
return c.DownloadWithFormat(ctx, id, "")
}
// Download fetches a file by uploaded hash, but it forces format conversion.
func (c *Client) DownloadWithFormat(ctx context.Context, id uuid.UUID, format string) ([]byte, string, error) {
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/files/%s?format=%s", id.String(), format), nil)
if err != nil {
return nil, "", err
}