Jason Caldwell wrote:Thanks for the heads up on this thread.This is not something that s2Member makes possible in the current release. At some point in the future, we may release a set of developer tools to assist with this. Until then, I would recommend this PHP class, using the
getObjectInfo() method. If we ever build a set of developer tools for S3, we would most likely base it on this class, which has already been well tested for some years now.
See:
http://undesigned.org.za/2007/10/22/ama ... umentationgetObjectInfo:
http://undesigned.org.za/2007/10/22/ama ... ObjectInfo
Many thanks for this Jason.
I wrote a couple of short-codes to bring back the file-size for example:
- Code: Select all
/*
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]";
}
}
}
All works well

other than when the filename has a + in the name.
S2member also fails, as written about in my new post.
