浏览器上传到Amazon S3的动态策略和签名创建

I would like to select a file in an HTML form and upload it directly to Amazon S3. I understand the principles of browser-based uploads to S3 using POST, but how can I create a policy and signature for the form if I haven't yet chosen a file to upload? Should I use AJAX to send the filename to my server and return an appropriate policy and signature based on the file extension?

You can use Ajax, Flash or any other method to upload the file to your server and then transfer it to the Amazon S3.