diff --git a/internal/client/client.go b/internal/client/client.go index 3edbf06..cf4d250 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -2,6 +2,7 @@ package client import ( "bytes" + "context" "encoding/json" "fmt" "io" @@ -294,7 +295,7 @@ func (c *Client) UploadFileContent(uploadID, fileName, contentType string, fileB body := &bytes.Buffer{} writer := multipart.NewWriter(body) partHeader := make(textproto.MIMEHeader) - partHeader.Set("Content-Disposition", multipart.FileContentDisposition("file", fileName)) + partHeader.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, strings.NewReplacer(`\`, `\\`, `"`, `\"`).Replace(fileName))) if contentType == "" { contentType = "application/octet-stream" } @@ -323,10 +324,9 @@ func (c *Client) UploadFileContent(uploadID, fileName, contentType string, fileB fmt.Printf("→ POST %s (multipart, %d bytes)\n", url, body.Len()) } - origTimeout := c.httpClient.Timeout - c.httpClient.Timeout = UploadTimeout - resp, err := c.httpClient.Do(req) - c.httpClient.Timeout = origTimeout + ctx, cancel := context.WithTimeout(context.Background(), UploadTimeout) + defer cancel() + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, fmt.Errorf("upload request failed: %w", err) }