UNSOLVED

mirando

updated

16 years ago

M

mirando

12 Posts

0

3302

July 14th, 2010 19:00

Atmos-PHP for PEER1 CloudOne - Creating, Listing & Uploading/Downloading Files

Hi all,

I'm using PEER1 CloudOne.

I can create an empty file in a PHP script  using the atmos-php framework with this code:


$_files = new EsuRestApi( $host, $port, $uid, $secret );

$file = $_files->createObject( $acl = NULL, $metadata = NULL, $data = 'createObject data',     $mimeType = 'text/plain');

echo 'Empty file created. The file id is '. $file .'';

How do you do this with the uploadHelper class?

Also, anybody know how to list files in the cloud via this framework via REST? I tried the following but got an error 1009.

$_files = new EsuRestApi( $host, $port, $uid, $secret );


try {

$_files->queryObjects('.jpg');

} catch (Exception $e) {
    echo 'Error: ',  $e->getMessage(), "\n";
    echo  'Code: ', $e->getCode(), "\n";
      
}



That code returns:

Error: The method specified in the request is not allowed for the  resource identified. Code: 1009

I don't even think I should post my uploadhelper code as it's obviously wrong...

Thanks!

  • mirando

    12 Posts

    612

    0

    Posted July 15th, 2010 09:00

    I was able to upload a file with the uploadHelper class to PEER 1 CloudOne storage:

    $_files = new EsuRestApi( $host, $port, $uid, $secret );
    $_upload = new UploadHelper($_files);

    $fp = 'test.txt';
    $id = $_upload->createObjectFromFile( $fp );
    if ($id) {
    echo "File $id created";
    } else {
    echo "File not created";
    }

    ?>

    I'm still working out the rest. Hope this helps somebody.

  • rbala1

    222 Posts

    612

    1

    Posted July 19th, 2010 08:00

    Mirando,

    Have you seen the unit test included with the wrappers?  The unit test should serve as a guide to implementing each method.


    Raj

  • mirando

    12 Posts

    612

    0

    Posted July 20th, 2010 09:00

    Raj,

    Thanks for that information. I wasn't able to run the test as it required PHPUnit, but I see the code now that you mention it. I thought it was part of the framework.

    Cheers.

    - Luis