I'm using Amazon S3 with a simple project, when the user uploads a file, I first use an XMLHTTPRequest to send the details to my database, then trigger the form POST that uploads the file straight to S3.
What I can't quite work out though is how to tell when the upload is done so I can update the display properly (I'm cheating at the moment and just updating the display once it's saved in the database, you can barely tell for small uploads, but obviously a problem in the long run.)
The S3 server appears to "cancel navigation" once the upload is complete, so the page doesn't reload - are there any events that are fired that I can use to detect when the upload is complete?
Thanks
EDIT: I'm using the form code from here http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html just added an onsubmit to the form that fires the XMLHTTPRequest to my own server before the form gets posted to amazon.
Amazon S3 won't trigger any kind of event, but your XMLHTTPRequest code should be able to trigger a callback when S3 returns an HTTP 200 status code.
If S3 isn't returning a successful response code, it's quite possible that S3 doesn't know that your upload is complete. Are you sending a
Content-Length
header as part of your request?Amazon S3 will redirect to the url specified in the
success_action_redirect
field or if that's not specified, it returns an empty document with the status code specified insuccess_action_status
.See the AWS docs for more details.