2013-10-12 131 views
0

之间复制我尝试使用方法CloudFiles无法虚拟目录

CF_container->copy_object_to('th/image_a.jpg',Object(CF_container),'th/image_a_copy.jpg') 

复制一对夫妇位于我的容器上的文件,但是当我尝试复制存在我得到这个消息的文件

Specified object 'container_name/th/image_a.jpg' did not exist as source to copy from or 'container_name' did not exist as target to copy to. 

我做错了什么?这个操作是不可能做到的?这个操作不允许?

感谢您的回答。

回答

3

看起来您正在使用来自php-cloudfiles的SDK。 copy_object_to函数可以在github上找到here

该库已被废除,用于php-opencloud。可以找到文档here

复制对象时使用的新函数是DataObject :: Copy,可以找到here

编程逻辑,以与PHP-opencloud库云文件对象的副本看起来像下面这样:

// we must include this file 
require_once "php-opencloud.php"; 

define('AUTHURL', RACKSPACE_US); 

// create new Rackspace connection 
$connection = new \OpenCloud\Rackspace(AUTHURL, 
       array('username' => USERNAME, 'apiKey' => APIKEY)); 

// connect to ObjectStore 
$object_store = $connection->ObjectStore(); 

// create a container named CONTAINER_NAME 
$cont = $ostore->Container(); 
$cont->Create(array('name'=>CONTAINER_NAME)); 

// create an object in that container 
$obj = $cont->DataObject(); 
$obj->Create(array('name' => 'test_obj', 'content_type' => 'text/plain'), __FILE__); 

// copy it to another object 
$target = $cont->DataObject(); 
$target->name = $obj->Name().'-COPY'; 
$obj->Copy($target); 

如果您无法升级到使用PHP-opencloud库,它看起来像另一个用户有一个类似的问题here并追踪到一个双重编码的斜线。