title: Direct (and simple!) AJAX upload to AWS S3 from (AngularJS) Single Page App
body: <p>I know there's been a lot of coverage on upload to AWS S3. However, I've been struggling with this for about 24 hours now and I have not found any answer that fits my situation.</p>
  
  <h2>What I'm trying to do</h2>
  
  <p>Upload a file to AWS S3 directly from my client to my S3 bucket. The situation is:</p>
  
  <ol>
  <li>It's a Single Page App, so upload request must be in AJAX</li>
  <li>My server and my client are <strong>not</strong> on the same domain</li>
  <li>The S3 bucket is of the newest sort (Frankfurt), for which some signature-generating libraries don't work (see below)</li>
  <li>Client is in AngularJS</li>
  <li>Server is in ExpressJS</li>
  </ol>
  
  <h2>What I've tried</h2>
  
  <ul>
  <li><a href="https://devcenter.heroku.com/articles/s3-upload-node">Heroku's article</a> on direct upload to S3. Doesn't fit my client/server configuration (plus it really does not fit harmoniously with Angular)</li>
  <li>ready-made directives like <a href="https://github.com/asafdav/ng-s3upload">ng-s3upload</a>. Does not work because their signature-generating algorithm is not accepted by recent s3 buckets.</li>
  <li>Manually creating a file upload directive and logic on the client like in <a href="http://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs">this article</a> (using <code>FormData</code> and Angular's <code>$http</code>). It consisted of getting a signed URL from AWS on the server (and that part worked), then AJAX-uploading to that URL. It failed with some mysterious CORS-related message (although I did set a CORS config on Heroku)</li>
  </ul>
  
  <p>It seems I'm facing 2 difficulties: having a file input that works in my Single Page App, and getting AWS's workflow right.</p>
  
  <h2>The kind of solution I'm looking for</h2>
  
  <p>If possible, I'd like to avoid 'all included' solutions that manage the whole process while hiding of all of the complexity, making it hard to adapt to special cases. I'd much rather have a simple explanation breaking down the flow of data between the various components involved, even if it requires some more plumbing from me.</p>