I'm trying to send binary data--a serialized Java object--via the
TaskOptions.payload() method, but can't figure out how to send and/or
read the data properly. First, I serialized an object to a byte[],
which I know is working properly. Then I set the byte[] as the task
payload via:

    TaskOptions.payload( byte[], contentType );

I've tried different values for contentType;
"application/octet-stream" and "application/x-java-serialized-object"
seemed like the two most reasonable, but this seems to have no effect.

In my task handler (a servlet), I read the data into a byte[] prior to
object deserialization via the following:

   byte[] bytesIn = new byte[ req.getContentLength() ];
   req.getInputStream().readLine( bytesIn, 0, bytesIn.length );

However, the byte[] I read in is not the same as the byte[] I wrote
out. Here are the first few bytes of the array as I wrote it to
TaskOptions.payload (this is cut-and-paste from the Eclipse debugger):

   -84, -19, 0, 5, 115, 114, 0, 38, 99, 111, 109, 46, 103, 111,

and here are the first few bytes I read in, which is tantalizingly
close to what was written out:

    63,  63, 5, 115, 114, 38, 99, 111, 109, 46, 103, 111

So then I tried a different tack. I converted the byte[] to a string
in the outward direction:

   TaskOptions.payload( new String( byte[] ) );

and then used req.getReader() to read it in my task handler:

   byte[] bytesIn = req.getReader().readLine().getBytes();

This time I got even closer to my original byte[], but it's still
missing all of the "0" bytes:

   -84, -19,  5, 115, 114,  38, 99, 111, 109, 46, 103, 111, 111

Note that in both cases, the content length reported in the request
header is smaller than the byte[] length when I invoked
TaskOptions.payload().

How do I send a byte[] as the task payload? Any clues would be appreciated.

Vince

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to