title: Amazon S3 POST upload (from iPhone)
body: <p>A bit of background: I am building an iPhone app with a complementary server backend (written in Rails or possibly Sinatra, but probably not relevant for this discussion). Part of the functionality involves uploading pictures from the iPhone to the server. These ultimately get stored on S3, so in order to simplify the app and conserve bandwidth, I would like to upload the pictures directly from the iPhone to S3, skipping my backend server.</p>
  
  <p>Using the S3 REST API (in which case I would likely use <a href="http://allseeing-i.com/ASIHTTPRequest/S3" rel="noreferrer">ASIHTTPRequest</a>) would mean storing the AWS key and secret in the iPhone app, which I don't want to do for security reasons.</p>
  
  <p>For similar reasons I don't want to make my S3 bucket publicly writable.</p>
  
  <p>Now it looks like S3 also has support for <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/UsingHTTPPOST.html" rel="noreferrer">browser-based uploads using POST</a>. If I understand it correctly, this works by generating a signed policy document on the server, which then allows the client app to directly POST the file to S3. It seems like in principle this should work not only for browsers, but also for iPhone apps.</p>
  
  <p>However, I have a hard time figuring out the exact way of getting this working (not the iPhone specific part, just S3 POST uploads in general). What information needs to be sent to the server in order to calculate the signature (e.g. does it need the file size or any other file information)? I'll dig through the official docs some more and start experimenting with this, but if anybody could point me to some tutorials or sample code, that would be much appreciated.</p>