results.go 705 B

1234567891011121314151617181920212223242526272829
  1. package imagedata
  2. import (
  3. "fmt"
  4. "io"
  5. "devel.mephi.ru/iacherepanov/openstack-gophercloud"
  6. )
  7. // UploadResult is the result of an upload image operation. Call its ExtractErr
  8. // method to determine if the request succeeded or failed.
  9. type UploadResult struct {
  10. gophercloud.ErrResult
  11. }
  12. // DownloadResult is the result of a download image operation. Call its Extract
  13. // method to gain access to the image data.
  14. type DownloadResult struct {
  15. gophercloud.Result
  16. }
  17. // Extract builds images model from io.Reader
  18. func (r DownloadResult) Extract() (io.Reader, error) {
  19. if r, ok := r.Body.(io.Reader); ok {
  20. return r, nil
  21. }
  22. return nil, fmt.Errorf("Expected io.Reader but got: %T(%#v)", r.Body, r.Body)
  23. }