首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cloudfiles远程文件问题

cloudfiles远程文件问题
EN

Stack Overflow用户
提问于 2011-03-14 08:33:53
回答 1查看 551关注 0票数 1

我正在尝试将文件从远程文件加载到我的云文件容器中。

以下是云文件支持人员给我的示例代码:

代码语言:javascript
复制
<?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);
?>

我得到的问题是下面的错误:

代码语言:javascript
复制
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

我不确定我在这里没有注意到什么。

EN

回答 1

Stack Overflow用户

发布于 2011-03-14 08:36:11

$conn似乎没有成功实例化对象。这就是问题所在,但解决方案并不明确。

是否定义了CF_Connectionerror_reporting(E_ALL)给你提供了更多有用的信息吗?var_dump($conn instanceof CF_Connection)会输出什么?

这应该会给你指明正确的方向。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5293556

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档