Ask Your Question
0

Is there a way to move/rename an object?

asked 2011-04-25 18:50:24 -0500

twkiel gravatar image

Lets say long ago I put an object in container X, and I need to rename the object within that container, or even move it to another container and rename it.

Is this possible without another client file transfer?

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2011-04-25 19:17:25 -0500

david-goetz gravatar image

There is a way to copy files. To do a rename/move, you'd have to delete the original as shown below. This is just copied from the CF developer guide:

4.3.3. Copy Object

Suppose you upload a file with the wrong object name or content type, or you needed to move some objects to another container. Without a server-side copy feature, you would need to repeat uploading the same content and then delete the existing object. With server-side object copy, you can save the step of re-uploading the content and thus also save the associated bandwidth charges, if any were to apply

There are two ways to copy an existing object to another object in Cloud Files. One way is to do a PUT to the new object (the target) location, but add the “X-Copy-From” header to designate the source of the data. The header value should be the container and object name of the source object in the form of “/container/object”. Also, the X-Copy-From PUT requests require a Content-Length header, even if it is zero (0). PUT /<api version="">/<account>/<container>/<destobject> HTTP/1.1 Host: <storage url=""> X-Auth-Token: <some-auth-token> X-Copy-From: /<container>/<sourceobject> Content-Length: 0

The second way to do an object copy is similar. Do a COPY to the existing object, and include the “Destination” header to specify the target of the copy. The header value is the container and new object name in the form of “/container/object”.

COPY /<api version="">/<account>/<container>/<sourceobject> HTTP/1.1 Host: <storage url=""> X-Auth-Token: <some-auth-token> Destination: /<container>/<destobject>

With both of these methods, the destination container must exist before attempting the copy. If you were wanting to perform a move of the objects rather than a copy, you would need to send a DELETE request to the old object. A move simply becomes a COPY + DELETE. All metadata is preserved during the object copy. Note that you can set metadata on the request to copy the object (either the PUT or the COPY) and the metadata will overwrite any conflicting keys on the target (new) object. One interesting use case is to copy an object to itself and set the content type to a new value. This is the only way to change the content type of an existing object.

edit flag offensive delete link more

Comments

It seems that the copy method can not copy file greater that 5GB?

Meteor gravatar imageMeteor ( 2016-06-27 02:05:33 -0500 )edit
0

answered 2011-04-26 02:16:28 -0500

hi

If i use one of that two methods to move/rename object(1,X-Copy-From 2,Destination), i want to know, if that will become a bottoleneck ?

In particular, there is a large number of users while simultaneously

Thks

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2011-04-25 18:50:24 -0500

Seen: 2,158 times

Last updated: Apr 26 '11