blob: b1aac8eb0d92f0ee4a1ccebbacfb8c1a80334ffb [file] [log] [blame]
jrperrittc5c590a2016-11-04 14:41:15 -05001package imagedata
2
3import (
4 "io"
5 "net/http"
6
7 "github.com/gophercloud/gophercloud"
8)
9
10// Upload uploads image file
11func Upload(client *gophercloud.ServiceClient, id string, data io.ReadSeeker) (r UploadResult) {
12 _, r.Err = client.Put(uploadURL(client, id), data, nil, &gophercloud.RequestOpts{
13 MoreHeaders: map[string]string{"Content-Type": "application/octet-stream"},
14 OkCodes: []int{204},
15 })
16 return
17}
18
19// Download retrieves file
20func Download(client *gophercloud.ServiceClient, id string) (r DownloadResult) {
21 var resp *http.Response
22 resp, r.Err = client.Get(downloadURL(client, id), nil, nil)
23 if resp != nil {
24 r.Body = resp.Body
25 r.Header = resp.Header
26 }
27 return
28}