I am using SWFUpload to upload files from the browser straight into Amazon S3, but the upload isn't working. Here's the SWFUpload debug log:
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for standard upload. Starting upload to https://s3.amazonaws.com/discuss-dev for File ID: SWFUpload_0_0 SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0 Bytes: 0. Total: 150904 SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 131072. Total: 150904 SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 150904. Total: 150904 SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 400. SWF DEBUG: Event: uploadComplete : Upload cycle complete.
SWFUpload reports that there is an HTTP 400 error (Bad Request), but it doesn't actually print out the error message. Firebug doesn't help here either because it doesn't record the request coming from the SWFUpload Flash object. (HTTPFox doesn't record that request either.)
To get the actual error code I had to use WireShark to listen in on all TCP packets going in and out of the computer.
Capture > Interfaces > en1 (in my case)
At this point I uploaded another file from SWFUpload. After the error appeared in the browser again and then stopped the packet capturing in Wireshark (clicked
Capture > Stop).
There was a lot of traffic coming from 126.96.36.199, so that's most likely the s3 server. A quick dns lookup confirms this.
$ host 188.8.131.52 184.108.40.206.in-addr.arpa domain name pointer s3-1.amazonaws.com.
Since Wireshark is capturing all traffic it's good to filter only the packets that have this IP as the source or destination.
Filter: "ip.addr == 220.127.116.11"
To see other filtering options you can click the 'Expression...' button
This is the full record of the packets that passed between my computer and the S3 server during the upload attempt. I'm interested in the HTTP 400 error, so this is the packet I'm looking for:
To see the http response from the amazon server right click the packet and select "Follow TCP Stream". Scroll down to the section that is hilighted in blue.
Tada! So error I was looking for is:
<code>InvalidArgument</code>Bucket POST must contain a field named 'key'. If it is specified, please check the order of the fields.