Merge pull request #8 from Ferada/fix-read-status-code
Handle error response when reading a file.
This commit is contained in:
commit
f60c73fbb4
@ -261,7 +261,12 @@ func (c *Client) ReadStream(path string) (io.ReadCloser, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newPathErrorErr("ReadStream", path, err)
|
return nil, newPathErrorErr("ReadStream", path, err)
|
||||||
}
|
}
|
||||||
|
if rs.StatusCode == 200 {
|
||||||
return rs.Body, nil
|
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 {
|
func (c *Client) Write(path string, data []byte, _ os.FileMode) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user