czaries — 2010-10-14T10:49:06-04:00 — #1
I am currently in the middle of writing a CMS for a client, and have come across the need for a file upload solution. I could do the standard hackey $FILES handling and file writing to a directory, etc. but the process of thinking about it has left me wondering if there is an existing solution that can do more. I checked out [ZendFile](http://framework.zend.com/manual/en/zend.file.html) and it left me a little disappointed.
It's okay to write the files to disk at first, but when you scale out you need to put the files elsewhere - Amazon S3, a CDN, separate networked servers, etc. Is there any existing solution that can handle file uploads through the same interface and is able to support multiple backends (I realize this might mean having to store the uploaded file in a local "/tmp" directory first as an intermediate step)?
ren — 2010-10-14T15:49:42-04:00 — #2
Haven't come across any existing solutions that I liked.
What I like doing is getting a hash of the contents (eg sha1) and store that in the database.
All the backend component implementations deal with the sha1 key.
So a file contents with sha1 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
So the basic directory implementation would map it to /somedir/2f/d4/2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 for example.