images service v2 port from rackpsace/gophercloud (#171)
* CheckByteArrayEquals funcs
* direct port from rackspace/gophercloud with minor additions to get unit tests passing
* new package for uploading and downloading image data
* updates to make imageservice v2 consistent with the rest of gophercloud/gophercloud
* add image service v2 client
diff --git a/openstack/imageservice/v2/imagedata/requests.go b/openstack/imageservice/v2/imagedata/requests.go
new file mode 100644
index 0000000..b1aac8e
--- /dev/null
+++ b/openstack/imageservice/v2/imagedata/requests.go
@@ -0,0 +1,28 @@
+package imagedata
+
+import (
+ "io"
+ "net/http"
+
+ "github.com/gophercloud/gophercloud"
+)
+
+// Upload uploads image file
+func Upload(client *gophercloud.ServiceClient, id string, data io.ReadSeeker) (r UploadResult) {
+ _, r.Err = client.Put(uploadURL(client, id), data, nil, &gophercloud.RequestOpts{
+ MoreHeaders: map[string]string{"Content-Type": "application/octet-stream"},
+ OkCodes: []int{204},
+ })
+ return
+}
+
+// Download retrieves file
+func Download(client *gophercloud.ServiceClient, id string) (r DownloadResult) {
+ var resp *http.Response
+ resp, r.Err = client.Get(downloadURL(client, id), nil, nil)
+ if resp != nil {
+ r.Body = resp.Body
+ r.Header = resp.Header
+ }
+ return
+}