Can the data not be passed simply as a ByteArray instead of a base64 string?
This is from
the Adobe documentation for URLRequest:
---------------------
data property
An object containing data to be transmitted with the URL request.
This property is used with the method property. In Adobe AIR, data is sent when
any HTTP
method other than GET is used. In Flash Player, data is set when the POST HTTP
method is
used.
The URLRequest API offers binary POST support and support for URL-encoded
variables,
as well as support for strings. The data object can be a ByteArray,
URLVariables, or String
object.
The way in which the data is used depends on the type of object used:
If the object is a ByteArray object, the binary data of the ByteArray object is
used as POST
data. For GET, data of ByteArray type is not supported.
-----------
My problem is that I am also deficient in my experience with servlets and don't
know how
to decode a byte array there, but this is how I send the byte array
var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(component);
var imageByteArray:ByteArray = imageSnap.data as ByteArray;
var request:URLRequest = new URLRequest(imgServURL);
request.data = imageByteArray;
request.method =
URLRequestMethod.POST;
navigateToURL(request);
--- In [email protected], leds usop <[EMAIL PROTECTED]> wrote:
>
> without remoting, and using string param only, encode the image as jpeg or
> png
(depending on your requirement) . then convert it to base64 string which you
can pass to
the serlvet via post (or get, whatever) . Then decode at the backend
accordingly as a jpeg
file or png file which is you can make available to the user. This is not the
fastest solution
performance-wise but it does get the job done expecially for snapshots.
>
> --- On Thu, 6/26/08, netdeep <[EMAIL PROTECTED]> wrote:
> From: netdeep <[EMAIL PROTECTED]>
> Subject: [flexcoders] image snapshot in flex
> To: [email protected]
> Date: Thursday, June 26, 2008, 12:47 AM
>
>
>
>
>
>
>
>
>
>
>
> I'd like to add a button so the user can snapshot a graph in my
> flex app. I can do
this storing
>
> it on the server with Java, but I'd like for the user to have direct access
> to it. Since I
don't
>
> think this can be done for instance saving to the desktop, I thought the next
> best
solution
>
> would be to send the image to say a new browser window, possibly via a
> servlet? But
I'm not
>
> sure how to do this or if this is the best solution. Any ideas or examples
> of how this
should
>
> be done? Here is a little snippet of the method I use to encode the image
> into a
byteArray:
>
>
>
> private function saveImage(e: ImageUpdateEvent ):void {
>
> var comp:UIComponent = e.comp;
>
> var imageSnap:ImageSnap shot = ImageSnapshot. captureImage(
> comp);
>
> var imageByteArray: ByteArray = imageSnap.data as ByteArray;
>
> imgSave.saveImage( imageByteArray, e.name+"-img. png");
>
> }
>