Handle error response when reading a file.
This commit is contained in:
parent
e3cd1f98e7
commit
a11466bd13
@ -261,7 +261,12 @@ func (c *Client) ReadStream(path string) (io.ReadCloser, error) {
|
||||
if err != nil {
|
||||
return nil, newPathErrorErr("ReadStream", path, err)
|
||||
}
|
||||
if rs.StatusCode == 200 {
|
||||
return rs.Body, nil
|
||||
} else {
|
||||
rs.Body.Close()
|
||||
return nil, newPathError("ReadStream", path, rs.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) Write(path string, data []byte, _ os.FileMode) error {
|
||||
|
Loading…
Reference in New Issue
Block a user