cloudfiles远程文件问题

发布于 2024-10-22 08:52:44 字数 1136 浏览 2 评论 0原文

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

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

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

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

I am trying to load a file to my Cloud Files Container from a remote file.

Below is the example code a Cloud Files Support person gave me:

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

The problem I am getting is the below error:

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

Not sure exactly what I am not noticing here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉月流沐 2024-10-29 08:52:44

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

CF_Connection 是否已定义? error_reporting(E_ALL) 是否能为您提供更多有用的信息? var_dump($conn instanceof CF_Connection) 输出什么?

这应该为您指明正确的方向。

It seems $conn did not successfully instantiate an object. That is the problem, but the solution is not clear cut.

Is CF_Connection defined? Does error_reporting(E_ALL) give you more helpful info? What does var_dump($conn instanceof CF_Connection) output?

This should point you in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文