h1vpdata
h1vpdata

Reputation: 331

flash upload to s3 using as3httpclient socket

I am trying to upload a jpeg to Amazon S3 from flash using a socket, I want to avoid the URLLoader and FileRefrence uploads other security policy issues that require user interactions. I want to be able to resize and encode the image into a ByteArray and upload the image based on an external interface call. I saw this example.

https://github.com/gabriel/as3httpclient/blob/master/test/s3/S3PostTest.as

I used the following crossdomain.xml

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<!-- Policy file for xmlsocket://socks.example.com -->
<cross-domain-policy> 
     <allow-access-from domain="*" to-ports="*" secure="false"/>
</cross-domain-policy>

and I got the preverbal

Error: Request for resource at xmlsocket://mybucket.s3.amazonaws.com:80 by requestor from http://mybucket.s3.amazonaws.com/swf/myswf.swf is denied due to lack of policy file permissions.

I know this uses a socket implementation but I do not know what i am missing at this point, does S3 not allow you to look up the policy file from a flash socket implementation over port 80 or 443? However it would not explain why this as3httpclient example is up there, anyone have any ideas?

Upvotes: 1

Views: 848

Answers (3)

jayarjo
jayarjo

Reputation: 16726

It doesn't work because in addition to Cross Domain Policy file, the server (S3 in your case) must allow you to make a successful socket connection to it through Socket Policy File Server. And S3 obviously is not running it.

Only web applications (Flash/Flex) require it, desktop apps (AIR, etc) can go through without Socket Policy File Server approval.

Upvotes: 0

h1vpdata
h1vpdata

Reputation: 331

I think the answer is that the as3httpclient code for Amazon S3 is for Adobe Air not Flash/Flex.

Checking the socket policy file over http does not work for me because flash still requires checking it over the socket on port 80 which fails (even though it is accepted over http).

Upvotes: 1

mems
mems

Reputation: 1254

If you want using Sockets (as3httpclient use socket for HTTP transactions handling), you need a crossdomain policy file.

It must be served by the same server (here http://mybucket.s3.amazonaws.com) as your socket destination point.

There is 2 way to do this: serve it via 843 port (XMLSocket transaction) or let it available through HTTP ex: http://mybucket.s3.amazonaws.com/crossdomain.xml and call Security.loadPolicyFile("http://mybucket.s3.amazonaws.com/crossdomain.xml"); in your application before any HTTP transaction.

References:

Upvotes: 0

Related Questions