Stream template upload (#6035)

Resolves #5718
This commit is contained in:
Ammar Bandukwala
2023-02-04 14:07:09 -06:00
committed by GitHub
parent 77fd34be94
commit a422cc00e8
12 changed files with 69 additions and 46 deletions
+6 -4
View File
@@ -109,10 +109,13 @@ func (c *Client) Request(ctx context.Context, method, path string, body interfac
var r io.Reader
if body != nil {
if data, ok := body.([]byte); ok {
switch data := body.(type) {
case io.Reader:
r = data
case []byte:
r = bytes.NewReader(data)
} else {
// Assume JSON if not bytes.
default:
// Assume JSON in all other cases.
buf := bytes.NewBuffer(nil)
enc := json.NewEncoder(buf)
enc.SetEscapeHTML(false)
@@ -120,7 +123,6 @@ func (c *Client) Request(ctx context.Context, method, path string, body interfac
if err != nil {
return nil, xerrors.Errorf("encode body: %w", err)
}
r = buf
}
}