Monday, December 4, 2006

Using php curl to access Amazon S3

I've been working with Amazon S3 for a bit. I had a need to upload large files (1gb+) to the Amazon S3 service. The problem is that the sample library uses file_get_contents to slurp up the file that is being uploaded and then spits it out to Amazon. This kills your server as it sucks up all your memory of couse :(

I found this piece of code that handles streaming files by using the php curl libraries http://blogs.missiondata.com/linux/49/s3-streaming-with-php/

Having an issue getting that to work but in the process decided to work on replacing the PEAR request.php code with curl. I never really liked the PEAR classes myself.

I've converted the following s3 methods so far:
createBucket()
deleteBucket()
listBucket()
listKeys()
getBucketACL()

You can get this code from my Caveman framework. (It's one of the stand-alone components)

http://code.google.com/p/cavemanframework/

No comments: