tags:

views:

1710

answers:

4

Hi everyone,

I'm new to Flex and couldn't figure out yet how to send binary data to the server as the body of a POST request. The HTTPService component doesn't seem to support this. The FileReference doesn't seem to support setting the data via the Flex API.

Unfortunately the answers to similar questions on stackoverflow.com haven't been very promising. Any new pointers would be greatly appreciated, thanks a lot!

-- Andreas

+1  A: 

I've never used Flex but I would imagine you would need to encode your binary data in ascii using something like http://en.wikipedia.org/wiki/Uuencoding

Tarski
+1  A: 

Post it using the URLLoader and URLRequest classes.

var urlLoader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest(url);
request.data = binaryData;
request.method = URLRequestMethod.POST
urlLoader.load(request);
Amarghosh
A: 

Depending on your goal, you may want to consider using AMF objects. google "flex actionscript" that assumes that you control the server. Zend AMF is a pretty good PHP AMF implementation.

PaulC
A: 

It's true, Flex's HTTPService does not support different enctypes. A good alternative I found and use is ru.inspirit.net.MultipartURLLoader found at http://code.google.com/p/in-spirit/source/browse/#svn/trunk/projects/MultipartURLLoader/ru/inspirit/net (MIT License). Works well! :)

gilm