0

I am trying to update header data of some Rackspace objects i have uploaded. Example header attribute like: X-Object-Meta-name

But to do that, currently i need to download the whole object and parse the header from the downloaded object. Then do some checking and update if necessary and then upload the object again. But this makes the updating process very slow.

Is there a way to only download the header part of an object and updating it alone? Thanks in advance!

Obaida.Opu
  • 444
  • 1
  • 4
  • 18

2 Answers2

0

https://github.com/jclouds/jclouds/blob/master/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java#L207

If you give it a map with "name"->"the updated header value", it should update the header and automatically add the x-object-meta- prefix.

zacksh
  • 196
  • 5
0

Is there a way to only download the header part of an object and updating it alone?

I am not a Java developer, but the Cloud Files API is a RESTful one, so I will provide examples using curl. If you are using a library then you may want to edit your question to include which library as many of them abstract these opperations and a better answer can probably be provided in the context of that library.

To download the headers without the object content, perform a HTTP HEAD request.

$ curl -I -XHEAD -H'X-Auth-Token:******' \
> https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_******/container/object
HTTP/1.1 200 OK
Content-Length: 400
Accept-Ranges: bytes
Last-Modified: Tue, 21 Apr 2015 12:06:23 GMT
Etag: 81dc9bdb52d04dc20036dbd8313ed055
X-Timestamp: 1429617982.70468
X-Object-Meta-Foo: Bar
Content-Type: text/html
X-Trans-Id: txd337e4634c98475baf1a4-0055363d42dfw1
Date: Tue, 21 Apr 2015 12:06:26 GMT

To update just the headers on the object, you can then perform a HTTP POST request.

$ curl -i -XPOST -H'X-Auth-Token:******' \
> -H'X-Object-Meta-Foo: Bar' \
> -H'X-Object-Meta-Foo2: Bar2' \
> https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_******/container/object
HTTP/1.1 202 Accepted
Content-Length: 76
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txc262dfe86727440cbfcb1-0055363d5cdfw1
Date: Tue, 21 Apr 2015 12:06:53 GMT

<html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>

Performing another HEAD requeset will show that both the headers are now present.

$ curl -I -XHEAD -H'X-Auth-Token:******' \
> https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_******/container/object
HTTP/1.1 200 OK
Content-Length: 400
Accept-Ranges: bytes
Last-Modified: Tue, 21 Apr 2015 12:06:53 GMT
Etag: 81dc9bdb52d04dc20036dbd8313ed055
X-Timestamp: 1429618012.98354
X-Object-Meta-Foo: Bar
X-Object-Meta-Foo2: Bar2
Content-Type: text/html
X-Trans-Id: txdd9365b54e8f4d8c8451d-0055363d6adfw1
Date: Tue, 21 Apr 2015 12:07:06 GMT
hurricanerix
  • 101
  • 3