简体   繁体   中英

How to copy a file between locations in a Rackspace Cloud Files container with their PHP API

Given the code

$this->cf_container->copy_object_to($file, $this->cf_container, $new_path . '/' . $file_subpath);

where $this->cf_container is an object of the CF_Container class, I get this error:

"Specified object 'A random container/one/pow/whiskey.jpg' did not exist as source to copy from or 'A random container' did not exist as target to copy to."

The container's name, obviously, is "A random container". I have tried this with a container that does not contain spaces to the same effect.

If I do a $this->cf_container->get_object($file) I get a CF_Object object with the file's properties, so it exists.

$file is equal to "one/pow/whiskey.jpg" $new_path is equal to "one/different_folder" $file_subpath is equal to "whiskey.jpg"

Anyone have a clue or has encountered this before?

You might want to try the new Rackspace PHP SDK (aka php-opencloud). The php-cloudfiles will eventually be deprecated.

To copy an object in php-opencloud check out DataObject::Copy . If you run into problems, you can file issues here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM