Some background - I started out with the goal of moving my moodle hosting to AWS, but came to the conclusion that it wasn't practical until Moodle can natively store files like the course backups to S3. Instead I decided to speed up my site by moving as many of the static files as I could to S3 - primarily the course images, but also the site logo, some static js and so on. The files are readable by the world on S3 (if they know the URL), so I only moved content which I don't mind anyone accessing. Also, I have been using moodle for 10 years (since v1.5), with courses which have been cloned as new courses year after year, resulting in lots of old obsolete legacy files that I just don't need clogging up the course backups, and making my moodledata directory unnecessarily large.
So, I wrote some code that looks through all of the lessons in a course, reads both legacy and new style images, pushes them to S3, and updates the course to point to the new location. It allows you to delete the old files after that is done - either fully deleting them if they are only in use by that course, or just unlinking then from the course if they are in use elsewhere. The net result for me is that page load time for the entire course (I have a bespoke printable page that shows me the entire course) is down from a typical full load time of 30s to 6s. 5s of the 6s is pulling together all of the lessons and assessment in to one page, so the image load time is down from 25s to 1s. The size of the backup of each course is down from about 10MB to about 100kB. And the daily cost of the S3 storage and serving up the files is a few cents. In short, it's a massive win for us.
I have attached my code in case anyone else finds this useful. To use it, you need to enter your account details against the S3 repository plugin. You'll also need to edit the code to enter your bucket name at line 78. Upload the aws library to your site from http://pear.amazonwebservices.com/get/aws.phar. I put both in a local plugin directory. Then you just call the file passing the parameter id=course number, e.g. http://www.mysite.com/local/myplugin/course_images_s3.php?id=123. Once the images have been moved, you can press the Delete button at the bottom of the screen. You'll need course update privileges to do all of the this.
The actual screen is messy - no navigation and so on. It's just something I wrote to get the job done for the way I use my site. However, it's robust, and anyone is free to use it as it, or make it better if they want. I'm sharing it in case anyone wants to do somthing similar - it might just save you a few days work. If you find it useful, let me know.