简体   繁体   English

Rackspace云文件使用PHP API创建容器,但不创建对象。 每次都有不同的错误?

[英]Rackspace cloudfiles PHP API creating container but not objects . Different errors everytime?

This is the simple code I`m using to upload an image in my rackspace account with PHP : 这是我用来通过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)
?>

Also everytime it gives diffrent errors. 同样,每次都会给出不同的错误。 Like: "Strict standards: Only variables should be passed by reference in C:\\wamp\\www\\cloudfiles.php on line 1969 " 像:“严格的标准:1969年的C:\\ wamp \\ www \\ cloudfiles.php中只能通过引用传递变量”

" Fatal error: Maximum execution time of 30 seconds exceeded in C:\\wamp\\www\\cloudfiles_http.php on line 1249" “致命错误:第1249行的C:\\ wamp \\ www \\ cloudfiles_http.php超过30秒的最大执行时间”

A sample of errors (imgur image) 错误样本(imgur图片)

Please help I`ve been trying this simple thing for 2 hours now. 请帮助我已经尝试了2个小时的简单操作。

Php-cloudfiles bindings are deprecated. php-cloudfiles绑定已弃用。 I suggest you to give php-opencloud a try. 我建议您尝试一下php-opencloud。 I shouldn't be hard to port your code. 我应该不难移植您的代码。 Here's a quick example: 这是一个简单的示例:

<?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);

You can find php-opencloud docs at: https://github.com/rackspace/php-opencloud/blob/master/docs/getting-started.md 您可以在以下位置找到php-opencloud文档: https//github.com/rackspace/php-opencloud/blob/master/docs/getting-started.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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