PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

File Size, Date and Checksum with S3 Downloads

Common Questions/Problems/Tips. Posted by Administrators & Support Reps.

File Size, Date and Checksum with S3 Downloads

Postby colinp386 » December 6th, 2011, 10:24 am

Hi There;

I would like to provide, file size, date and checksum of the files being downloaded from Amazon's S3 service.
How easy would that be to do with after the download had been completed or while it's in process.

Seems like this would be a nice feature to add, for those who like to check the integrity of their downloads
S3 stores this info in their store.

Many thanks.

Colin
Colin Prior


UnixPackages - Open Source Packages for Solaris
User avatar
colinp386
Registered User
Registered User
 
Posts: 28
Joined: September 29, 2011

Re: File Size, Date and Checksum with S3 Downloads

Postby colinp386 » December 16th, 2011, 12:24 pm

Still looking to get an idea if this is a possibility at some point :-)
Colin Prior


UnixPackages - Open Source Packages for Solaris
User avatar
colinp386
Registered User
Registered User
 
Posts: 28
Joined: September 29, 2011

Re: File Size, Date and Checksum with S3 Downloads

Postby Cristián Lávaque » December 18th, 2011, 3:59 pm

Thanks for the suggetion, Colin. I'll forward it to the Lead Developer. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: File Size, Date and Checksum with S3 Downloads

Postby Jason Caldwell » December 19th, 2011, 11:50 am

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 ... umentation
getObjectInfo: http://undesigned.org.za/2007/10/22/ama ... ObjectInfo
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: File Size, Date and Checksum with S3 Downloads

Postby colinp386 » December 19th, 2011, 1:21 pm

Thanks for the suggestion, likely I can find a way to incorporate that into my current display code, let me try. In the mean time thanks for thinking of considering incorporating into a list of dev tools

Colin
Colin Prior


UnixPackages - Open Source Packages for Solaris
User avatar
colinp386
Registered User
Registered User
 
Posts: 28
Joined: September 29, 2011

Re: File Size, Date and Checksum with S3 Downloads

Postby colinp386 » December 30th, 2011, 1:55 am

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 ... umentation
getObjectInfo: 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 :mrgreen: other than when the filename has a + in the name.
S2member also fails, as written about in my new post. :?
Colin Prior


UnixPackages - Open Source Packages for Solaris
User avatar
colinp386
Registered User
Registered User
 
Posts: 28
Joined: September 29, 2011

Re: File Size, Date and Checksum with S3 Downloads

Postby Jason Caldwell » December 30th, 2011, 9:44 pm

Thanks for the update. Glad to hear this all worked out for you.
I see you solved the other issue with + file names as well.

I posted a quick reply in this thread, and we'll take a closer look at implementing a patch in the next release: viewtopic.php?f=4&t=16611&p=59297#p59297
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to Common Questions/Problems/Tips

Who is online

Users browsing this forum: No registered users and 1 guest

cron