2011-03-14 9 views
1

원격 파일에서 Cloud Files Container로 파일을로드하려고합니다. 다음은 cloudfiles 원격 파일 문제

는 클라우드 파일 지원 사람이 내게 준 예제 코드입니다 :

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

$conn 개체를 성공적으로 인스턴스화하지 못했습니다. 이것이 문제이지만 해결책은 명확하지 않습니다.

CF_Connection이 정의되어 있습니까? error_reporting(E_ALL)에게 도움이되는 정보가 있습니까? var_dump($conn instanceof CF_Connection)의 출력은 무엇입니까?

올바른 방향으로 알려야합니다.

+0

'cloudfiles.php'에 있어야하며 'CF_Auth'는 전에 오류가있는 것 같습니까? – ian

+0

@ian 다시 확인하십시오. 때로는 가정이 잘못되었습니다. :) – alex

+0

'var_dump'가'Notice : Undefined variable : conn /home2/sharingi/public_html/daily_dose/remote_test.php 5 행에 있습니다. bool (false)'와'error_reporting'는 을 반환합니다. 알림 : 정의되지 않은 오프셋 : 8 in /home2/sharingi/public_html/daily_dose/cloud/cloudfiles.php on line 1588' – ian