Use a ReadSeeker for upload content and rewind the offset on retries
diff --git a/rackspace/objectstorage/v1/objects/delegate.go b/rackspace/objectstorage/v1/objects/delegate.go
index 028d66a..94c820b 100644
--- a/rackspace/objectstorage/v1/objects/delegate.go
+++ b/rackspace/objectstorage/v1/objects/delegate.go
@@ -33,7 +33,7 @@
}
// Create is a function that creates a new object or replaces an existing object.
-func Create(c *gophercloud.ServiceClient, containerName, objectName string, content io.Reader, opts os.CreateOptsBuilder) os.CreateResult {
+func Create(c *gophercloud.ServiceClient, containerName, objectName string, content io.ReadSeeker, opts os.CreateOptsBuilder) os.CreateResult {
return os.Create(c, containerName, objectName, content, opts)
}
diff --git a/rackspace/objectstorage/v1/objects/delegate_test.go b/rackspace/objectstorage/v1/objects/delegate_test.go
index 8ab8029..3431056 100644
--- a/rackspace/objectstorage/v1/objects/delegate_test.go
+++ b/rackspace/objectstorage/v1/objects/delegate_test.go
@@ -1,7 +1,7 @@
package objects
import (
- "bytes"
+ "strings"
"testing"
os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects"
@@ -68,7 +68,7 @@
defer th.TeardownHTTP()
os.HandleCreateTextObjectSuccessfully(t)
- content := bytes.NewBufferString("Did gyre and gimble in the wabe")
+ content := strings.NewReader("Did gyre and gimble in the wabe")
options := &os.CreateOpts{ContentType: "text/plain"}
res := Create(fake.ServiceClient(), "testContainer", "testObject", content, options)
th.AssertNoErr(t, res.Err)
@@ -79,7 +79,7 @@
defer th.TeardownHTTP()
os.HandleCreateTypelessObjectSuccessfully(t)
- content := bytes.NewBufferString("The sky was the color of television, tuned to a dead channel.")
+ content := strings.NewReader("The sky was the color of television, tuned to a dead channel.")
res := Create(fake.ServiceClient(), "testContainer", "testObject", content, &os.CreateOpts{})
th.AssertNoErr(t, res.Err)
}