How to upload files straight to S3 without using local storage? [closed]

I had this same requirement: my VPS lacked disk space, but I still wanted to manage photos with WordPress. tantan-s3 did not suffice, since a copy of every photo is stored locally.

It’s possible to abstract file storage using PHP stream wrappers, but a couple pieces of core WordPress are incompatible. So that’s the short answer: WordPress natively doesn’t support enough functionality to make this possible.


Moving on: WordPress ticket #18543 concerns itself with patching core to support stream wrappers in imagejpeg() (and other GD functions) and wp_mkdir_p().

Zend_Service_Amazon_S3_Stream provides an S3 stream wrapper, but it tends to be inefficient, requesting the default 8192 bytes at a time rather than buffering more, generating a huge number of requests in the process. I’ve been sitting on this for months, so I might as well release the mods into the wild. This patch works against Zend Framework 1.11.10.

Completing the circle is a plugin to translate the upload path to S3.

I would love to see someone take this further than I have, but it won’t get far until core WordPress improves stream support.

Leave a Comment