github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/imageservice/v2/imagedata/results.go (about)

     1  package imagedata
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/huaweicloud/golangsdk"
     7  )
     8  
     9  // UploadResult is the result of an upload image operation. Call its ExtractErr
    10  // method to determine if the request succeeded or failed.
    11  type UploadResult struct {
    12  	golangsdk.ErrResult
    13  }
    14  
    15  // StageResult is the result of a stage image operation. Call its ExtractErr
    16  // method to determine if the request succeeded or failed.
    17  type StageResult struct {
    18  	golangsdk.ErrResult
    19  }
    20  
    21  // DownloadResult is the result of a download image operation. Call its Extract
    22  // method to gain access to the image data.
    23  type DownloadResult struct {
    24  	golangsdk.Result
    25  	Body io.ReadCloser
    26  }
    27  
    28  // Extract builds images model from io.Reader
    29  func (r DownloadResult) Extract() (io.ReadCloser, error) {
    30  	if r.Err != nil {
    31  		return nil, r.Err
    32  	}
    33  	return r.Body, nil
    34  }