[英]CloudFiles cannot to copy between virtual directory
I try to copy a couple of files located on my container using the method 我尝试使用方法复制位于容器上的几个文件
CF_container->copy_object_to('th/image_a.jpg',Object(CF_container),'th/image_a_copy.jpg')
But when I try to copy a file that exists I got this message 但是,当我尝试复制存在的文件时,出现此消息
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.
What I doing wrong? 我做错了什么? This operation is impossible to do? 这个操作是不可能做到的? This operation cannot allowed? 不能进行此操作吗?
Thanks for your answer. 感谢您的回答。
It looks like you're using the SDK from php-cloudfiles. 看来您正在使用php-cloudfiles中的SDK。 The copy_object_to function can be found on github here . copy_object_to函数可以在github上找到 。
That library has been deprecated in favor of php-opencloud . 该库已不推荐使用php-opencloud 。 The documentation can be found here 该文档可以在这里找到
The new function to use when copying an object is DataObject::Copy and can be found here . 复制对象时使用的新函数是DataObject :: Copy,可以在此处找到。
The programming logic to make a copy of a Cloud Files object with the php-opencloud library would look something like the following: 使用php-opencloud库复制Cloud Files对象的编程逻辑如下所示:
// 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);
If you are unable to upgrade to using the php-opencloud library, it looks like another user had a similar problem here and tracked it down to a double-encoded slash. 如果您无法升级到使用php-opencloud库,则似乎另一个用户在这里遇到了类似的问题,并将其跟踪到一个双编码的斜杠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.