Statistics: Posted by Jason Caldwell — December 30th, 2011, 9:44 pm
/*
Shortcode to return filesize and checksum from Amazon S3
install S3.php class file in mu-plugin dir.
call with [get-s3fileinfo]URI of object[/get-s3fileinfo]
*/
add_shortcode('get-s3fileinfo', 'get_s3fileinfo');
function get_s3fileinfo($atts, $content = null){
//include the S3 class in case mu_plugin fails
if (!class_exists('S3'))require_once('S3.php');
//AWS access info
if (!defined('awsAccessKey')) define('awsAccessKey', 'Input access key here');
if (!defined('awsSecretKey')) define('awsSecretKey', 'Input Sectret key here');
//instantiate the class
$s3 = new S3(awsAccessKey, awsSecretKey);
$bucket = 'Bucket-Name';
$uri = $content;
if (($info = $s3->getObjectInfo($bucket, $uri)) !== false) {
/*print_r($info);*/
if (is_array ($info) && !empty ($info))
{
echo "Checksum: $info[hash]";
echo "<br/>";
echo "File size: $info[size]";
}
}
}
Statistics: Posted by colinp386 — December 30th, 2011, 1:55 am
Statistics: Posted by colinp386 — December 19th, 2011, 1:21 pm
Statistics: Posted by Jason Caldwell — December 19th, 2011, 11:50 am
Statistics: Posted by Cristián Lávaque — December 18th, 2011, 3:59 pm
Statistics: Posted by colinp386 — December 16th, 2011, 12:24 pm
Statistics: Posted by colinp386 — December 6th, 2011, 10:24 am