Write writes data to a given path
(path string, data []byte, _ os.FileMode)
| 435 | |
| 436 | // Write writes data to a given path |
| 437 | func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) { |
| 438 | s, err := c.put(path, bytes.NewReader(data), nil) |
| 439 | if err != nil { |
| 440 | return |
| 441 | } |
| 442 | |
| 443 | switch s { |
| 444 | |
| 445 | case 200, 201, 204: |
| 446 | return nil |
| 447 | |
| 448 | case 409: |
| 449 | err = c.createParentCollection(path) |
| 450 | if err != nil { |
| 451 | return |
| 452 | } |
| 453 | |
| 454 | s, err = c.put(path, bytes.NewReader(data), nil) |
| 455 | if err != nil { |
| 456 | return |
| 457 | } |
| 458 | if s == 200 || s == 201 || s == 204 { |
| 459 | return |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | return newPathError("Write", path, s) |
| 464 | } |
| 465 | |
| 466 | // WriteStream writes a stream |
| 467 | func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode, callback func(r *http.Request)) (err error) { |
no test coverage detected