Ejemplo n.º 1
0
<?php

require_once __DIR__ . '/config.php';
require 'ExampleTools.php';
require 'API.php';
// $consumerKey = $_SERVER['argv'][1];
// $consumerSecret = $_SERVER['argv'][2];
// $accessToken = $_SERVER['argv'][3];
// $tokenSecret = $_SERVER['argv'][4];
// $cloudPath = $_SERVER['argv'][5];
// $localPath = $_SERVER['argv'][6];
$cloudPath = $_GET["path"];
// Create a cloud api connection to copy
$ca = new \Barracuda\Copy\API($consumerKey, $consumerSecret, $token, $tokenSecret);
// Ensure the file exists
$files = $ca->listPath($cloudPath, array("include_parts" => true));
if (!$files) {
    die("Object " . $cloudPath . " doesn't exist\n");
}
// Found it, verify its a file
foreach ($files as $file) {
    if ($file->{"type"} != "file") {
        die("Object " . $file->{"path"} . " is not a file, can't download\n");
    }
    // print("Downloading " . $file->{"path"} . " to $localPath\n");
    // var_dump($file);
    header("Content-Type: application/download");
    header("Content-disposition: attachment; filename=" . basename($file->{"path"}));
    // Ok its a file, grab its parts
    // $fh = fopen($localPath, "a+b");
    foreach ($file->{"revisions"}[0]->{"parts"} as $part) {
Ejemplo n.º 2
0
<?php

require __DIR__ . '/../vendor/autoload.php';
include 'ExampleTools.php';
$consumerKey = $_SERVER['argv'][1];
$consumerSecret = $_SERVER['argv'][2];
$accessToken = $_SERVER['argv'][3];
$tokenSecret = $_SERVER['argv'][4];
$cloudPath = $_SERVER['argv'][5];
// Create a cloud api connection to copy
$ca = new \Barracuda\Copy\API($consumerKey, $consumerSecret, $accessToken, $tokenSecret);
print "Listing {$cloudPath}\n";
$children = $ca->listPath($cloudPath);
foreach ($children as $child) {
    printf("%5.5s %10.10s ", $child->{"type"}, humanFileSize($child->{"size"}));
    echo basename($child->{"path"}) . PHP_EOL;
}
Ejemplo n.º 3
0
<?php

require __DIR__ . '/../vendor/autoload.php';
include 'ExampleTools.php';
$consumerKey = $_SERVER['argv'][1];
$consumerSecret = $_SERVER['argv'][2];
$accessToken = $_SERVER['argv'][3];
$tokenSecret = $_SERVER['argv'][4];
$localPath = $_SERVER['argv'][5];
$cloudPath = $_SERVER['argv'][6];
// Create a cloud api connection to copy
$ca = new \Barracuda\Copy\API($consumerKey, $consumerSecret, $accessToken, $tokenSecret);
// Ensure the local file exists
$fh = fopen($localPath, "rb");
if (!$fh) {
    die("Failed to open {$localPath}\n");
}
// Send it up, 1MB at a time
print "Sending {$localPath} to {$cloudPath}\n";
$parts = array();
while ($data = fread($fh, 1024 * 1024)) {
    array_push($parts, $ca->sendData($data));
}
fclose($fh);
// Now update the file in the cloud
$ca->createFile($cloudPath, $parts);
print "Successfully created/modified file {$cloudPath} . \n";
Ejemplo n.º 4
0
<?php

require_once __DIR__ . '/config.php';
require 'ExampleTools.php';
require 'API.php';
// $consumerKey = $_SERVER['argv'][1];
// $consumerSecret = $_SERVER['argv'][2];
// $accessToken = $_SERVER['argv'][3];
// $tokenSecret = $_SERVER['argv'][4];
// $cloudPath = $_SERVER['argv'][5];
// Create a cloud api connection to copy
$ca = new \Barracuda\Copy\API($consumerKey, $consumerSecret, $token, $tokenSecret);
print "Listing root<br>";
$children = $ca->listPath('/');
foreach ($children as $child) {
    printf("%5.5s || %10.10s || ", $child->{"type"}, humanFileSize($child->{"size"}));
    echo basename($child->{"path"}) . PHP_EOL;
    $path = $child->{"path"};
    if ($child->{"type"} == "file") {
        echo "<a href='GetFile.php?path={$path}'>Download</a>";
    }
    echo "<br>";
}