![](/img/trans.png)
[英]rackspace cloudfiles api - most efficient method to return container files
[英]Rackspace cloudfiles PHP API creating container but not objects . Different errors everytime?
这是我用来通过PHP在机架帐户中上传图像的简单代码:
<?php
$api_username = 'lolcat';
$api_key = 'sexyapi';
require 'cloudfiles.php';
$auth = new CF_Authentication($api_username, $api_key);
$auth->authenticate();
$connection = new CF_Connection($auth);
$images = $connection->create_container("pitch");
$url = $images->make_public();
echo 'The url is '.$url;
$file = 'sherlock.jpg';
$img = $images->create_object($file);
$img->load_from_filename($file)
?>
同样,每次都会给出不同的错误。 像:“严格的标准:1969年的C:\\ wamp \\ www \\ cloudfiles.php中只能通过引用传递变量”
“致命错误:第1249行的C:\\ wamp \\ www \\ cloudfiles_http.php超过30秒的最大执行时间”
请帮助我已经尝试了2个小时的简单操作。
php-cloudfiles绑定已弃用。 我建议您尝试一下php-opencloud。 我应该不难移植您的代码。 这是一个简单的示例:
<?php
require 'vendor/autoload.php';
use OpenCloud\Rackspace;
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => 'foo',
'apiKey' => 'bar'
));
$service = $client->objectStoreService('cloudFiles', 'DFW');
$container = $service->createContainer('pitch');
$container->enableCdn();
$cdn = $container->getCdn();
//Print "Container SSL URL: " . serialize($cdn);
$files = array(
array(
'name' => 'file_1.txt',
'body' => fopen('files/file_1.txt', 'r+')
)
);
$container->uploadObjects($files);
您可以在以下位置找到php-opencloud文档: https : //github.com/rackspace/php-opencloud/blob/master/docs/getting-started.md
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.