我正在尝试从远程文件将文件加载到我的Cloud Files容器中。
以下是云文件支持人员给我的示例代码:
<?php
require('cloud/cloudfiles.php');
$res = fopen("http://images.piccsy.com/cache/images/66653-d71e1b-320-469.jpg", "rb");
$temp = tmpfile();
$size = 0.0;
while (!feof($res))
{
$bytes = fread($res, 1024);
fwrite($temp, $bytes);
$size += (float) strlen($bytes);
}
fclose($res);
fseek($temp, 0);
//
$auth = new CF_Authentication('user','token ');
//Calling the Authenticate method returns a valid storage token and allows you to connect to the CloudFiles Platform.
$auth->authenticate();
$conn = new CF_Connection($auth);
$container = $conn->create_container("example");
$object = $container->create_object("example.jpg");
$object->content_type = "image/jpeg";
$object->write($temp, $size);
fclose($temp);
?>
我遇到的问题是以下错误:
Fatal error: Call to a member function create_container() on a non-object in /home2/sharingi/public_html/daily_dose/remote_test.php on line 24
不确定我在这里没注意到什么。
答案 0 :(得分:0)
似乎$conn
没有成功实例化对象。这就是问题,但解决方案并不明确。
是否定义了CF_Connection
? error_reporting(E_ALL)
会为您提供更多有用的信息吗? var_dump($conn instanceof CF_Connection)
输出了什么?
这应该指向正确的方向。