Codebase list golang-github-nlopes-slack / 2f055ee
Only make filename mandatory if Reader is primary method of specifying files Zain Patel authored 4 years ago James committed 4 years ago
1 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
287287 if err != nil {
288288 return nil, err
289289 }
290 if params.Filename == "" {
291 return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory")
292 }
293290 response := &fileResponseFull{}
294291 values := url.Values{
295292 "token": {api.token},
318315 } else if params.File != "" {
319316 err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", values, response, api)
320317 } 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 }
321321 err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", values, params.Reader, response, api)
322322 }
323323 if err != nil {