(body string)
| 409 | } |
| 410 | |
| 411 | func createBody(body string) io.Reader { |
| 412 | if strings.HasPrefix(body, "@") { |
| 413 | filename := body[1:] |
| 414 | f, err := os.Open(filename) |
| 415 | if err != nil { |
| 416 | log.Fatalf("failed to open data file %s: %v", filename, err) |
| 417 | } |
| 418 | return f |
| 419 | } |
| 420 | return strings.NewReader(body) |
| 421 | } |
| 422 | |
| 423 | // getFilenameFromHeaders tries to automatically determine the output filename, |
| 424 | // when saving to disk, based on the Content-Disposition header. |