rulururu

post Error #2176 while trying upload file to amazon s3

May 26th, 2011

Filed under: Flash/Flex — Alex Bylim @ 2:26 am

I were working on uploading files to amazon s3 server, of course I used some ready class for this called AWS3. When I choose some file using FileReference and send it to amazon s3 servers everything ok. But when I’m trying to upload file using ByteArray I get error #2176 saying about some user interaction should be there(mouse click for example) in the same action stack to send file. Very weird stuff, but everybody knows that annoying adobe security policy. What I hade in the code is:

var urlRequest:URLRequest = new URLRequest();
urlRequest.contentType = 'multipart/form-data;';

But this wont work!

So there is very easy solution. Instead of using code above use code below:

var urlRequest:URLRequest = new URLRequest();
urlRequest.requestHeaders.push(new URLRequestHeader('Content-type', 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary()));

You can find UploadPostHelper in the internet.

ruldrurd
Powered by WordPress, Web Design by Laurentiu Piron
Entries (RSS) and Comments (RSS)