PHP code example of nao-pon / copy

1. Go to this page and download the library: Download nao-pon/copy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nao-pon / copy example snippets


// create a cloud api connection to Copy
$copy = new \Barracuda\Copy\API($consumerKey, $consumerSecret, $accessToken, $tokenSecret);

// list items in the root
$items = $copy->listPath('/');

// open a file to upload
$fh = fopen('/tmp/file', 'rb');

// upload the file in 1MB chunks
$parts = array();
while ($data = fread($fh, 1024 * 1024)) {
    $part = $copy->sendData($data);
    array_push($parts, $part);
}

// close the file
fclose($fh);

// finalize the file
$copy->createFile('/copy-file-path', $parts);

// obtain a list of files and parts
$files = $copy->listPath('/copy-file-path', array("s in the latest revision
    foreach ($file->revisions[0]->parts as $part) {
        $data .= $copy->getPart($part->fingerprint, $part->size);
    }
}

$copy->removeFile('/copy-file-path');

$copy->rename('/source-copy-file-path', '/destination-copy-file-path');


bash
# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add Copy API as a dependency
php composer.phar 
bash
export CONSUMER_KEY=<check the developer portal>
export CONSUMER_SECRET=<check the developer portal>
export ACCESS_TOKEN=<OAuth token>
export ACCESS_TOKEN_SECRET=<OAuth secret>