PHP classes for Amazon SQS and SimpleDB

Dan Myers has written some PHP classes for Amazon SQS and SimpleDB based on the S3 PHP class:

Posted in Uncategorized | Tagged | 5 Comments

WordPress plugin for Amazon S3

Update: 2011/06/12 – This won’t be of much use to you, I have a much better plugin in the works that’s almost production ready and will be released soon.

I’ve created a very simple WordPress plugin for Amazon S3 which uses my Amazon S3 PHP class.

Currently it allows you to upload files to an S3 bucket and insert them into your post when adding media.

Please note that PHP 5 and the CURL extension are required.

Download the latest version of the plugin.

To install place s3uploader.php into your wp-content/plugins/ directory. After activating the plugin you will need to configure your AWS credentials under Settings – Amazon S3 and select the bucket you would like to upload to.

Planned features for upcoming releases

  • Image resizing
  • Bucket browsing functionality under the media library

Changelog

  • 0.2 (2009-03-07):
    Some improvements and support for file downloads and flash movies
  • 0.1 (2009-02-16):
    Initial release
Posted in Uncategorized | Tagged , , | 2 Comments

Tracking file downloads with Google Analytics and Prototype

Using Prototype’s CSS-style selectors you can easily track file downloads with Google Analytics:

Event.observe(window, 'load', function() {
	$$('a[href$=".zip"]', 'a[href$=".pdf"]').each(function(anchor) {
		anchor.observe('click', function(event) {
			if (pageTracker) pageTracker._trackPageview(anchor.getAttribute('href'));
		});
	});
});
Posted in Uncategorized | Tagged , , | Leave a comment

Simple PHP upload progress meter using Prototype

The uploadprogress extension is fairly simple to use – but it is important to note that on some PHP configurations it doesn’t function correctly and only returns a progress of 100%.

Upload progress screenshot

The JavaScript uses David Stone’s method for displaying percentage bars but you can modify the onCreate, onUpdate and onComplete callbacks if you want to use your own.

1) You will need uploadprogress >= 0.3.1 (0.3.0 does not seem to work for me), to build it from source (don’t forget to restart your webserver after installing):


cvs -d :pserver:cvsread@cvs.php.net:/repository checkout pecl/uploadprogress
cd pecl/uploadprogress && phpize && ./configure && make && sudo make install

2) Progress tracking is automatically enabled if you have a field named UPLOAD_IDENTIFIER with a unique ID in your file upload form:

<input type="hidden" name="UPLOAD_IDENTIFIER" value="<?php echo $uploadID; ?>" id="uploadIdentifier" />

3) You retrieve the upload progress with your UPLOAD_IDENTIFIER (obviously these calls will be AJAX requests):

$data = uploadprogress_get_info($uploadID);

Once the upload is complete the extension will remove the temporary file and further info calls will return null.

That’s it!

See the demo

Download the code

Posted in Uncategorized | Tagged , | 8 Comments