Skip to content

Commit 2f055ee

Browse files
mzjp2james-lawrence
authored andcommitted
Only make filename mandatory if Reader is primary method of specifying files
1 parent 9966997 commit 2f055ee

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

files.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam
288288
if err != nil {
289289
return nil, err
290290
}
291-
if params.Filename == "" {
292-
return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory")
293-
}
294291
response := &fileResponseFull{}
295292
values := url.Values{
296293
"token": {api.token},
@@ -319,6 +316,9 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam
319316
} else if params.File != "" {
320317
err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", values, response, api)
321318
} else if params.Reader != nil {
319+
if params.Filename == "" {
320+
return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory when using FileUploadParameters.Reader")
321+
}
322322
err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", values, params.Reader, response, api)
323323
}
324324
if err != nil {

0 commit comments

Comments
 (0)