Only make filename mandatory if Reader is primary method of specifying files
Zain Patel authored 4 years ago
James committed 4 years ago
287 | 287 | if err != nil { |
288 | 288 | return nil, err |
289 | 289 | } |
290 | if params.Filename == "" { | |
291 | return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory") | |
292 | } | |
293 | 290 | response := &fileResponseFull{} |
294 | 291 | values := url.Values{ |
295 | 292 | "token": {api.token}, |
318 | 315 | } else if params.File != "" { |
319 | 316 | err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", values, response, api) |
320 | 317 | } else if params.Reader != nil { |
318 | if params.Filename == "" { | |
319 | return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory when using FileUploadParameters.Reader") | |
320 | } | |
321 | 321 | err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", values, params.Reader, response, api) |
322 | 322 | } |
323 | 323 | if err != nil { |