Skip to content

Commit

Permalink
Only make filename mandatory if Reader is primary method of specifyin…
Browse files Browse the repository at this point in the history
…g files
  • Loading branch information
mzjp2 authored and james-lawrence committed Aug 31, 2019
1 parent 9966997 commit 2f055ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam
if err != nil {
return nil, err
}
if params.Filename == "" {
return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory")
}
response := &fileResponseFull{}
values := url.Values{
"token": {api.token},
Expand Down Expand Up @@ -319,6 +316,9 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam
} else if params.File != "" {
err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", values, response, api)
} else if params.Reader != nil {
if params.Filename == "" {
return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory when using FileUploadParameters.Reader")
}
err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", values, params.Reader, response, api)
}
if err != nil {
Expand Down

0 comments on commit 2f055ee

Please sign in to comment.