I think I just found the answer...

For requests with body content that is not a set of CGI parameters,
such as the body of an HTTP PUT request, the request object provides
the attributes body and body_file. body is the body content as a byte
string. body_file provides a file-like interface to the same data.

uploaded_file = self.request.body

http://code.google.com/appengine/docs/python/tools/webapp/requestdata.html

tom



On Feb 1, 12:22 pm, tom s <tcs2...@gmail.com> wrote:
> Hi,
>
> I'm trying to send a bytearray from a Flash app to GAE, and store it
> as a db.BlobProperty.
> I think I have the actionscript correct (see below), but I don't know
> how to get a reference the object in GAE.
> So when I write:
>
> self.request.get(???)
>
> I don't know what to put in '???'.
> When I have been passing URL encoded variables (which works fine) I
> have used the variable name, but in this case there is no variable
> name, The URL request is just a POST of binary data. Presumably there
> is a default name for accessing such data - but what is it?
>
> See below for GAE code and ActionScript. (BTW - I can see from the
> debug that the size of 'CONTENT_LENGTH' changes as I change the array
> size, so I think the bytearray is being POSTed.
>
> Also, where is the language reference for self.request.get()?
> I'd love to be able to look this up myself, but I dont know where it
> is defined.
>
> thanks
>
> tom
>
> Here's my GAE code:
>
> class TestData(db.Model):
>
>     s = db.StringProperty()
>     d = db.BlobProperty()
>     l = db.ListProperty(int)
>
> class Byte(webapp.RequestHandler):
>     def get(self):
>
>         foo = bar
>
>     def post(self):
>         t = TestData()
>         t.s = "byte array"
>         t.d= db.Blob(self.request.get(???))
>         t.put()
>
> ActionScript Code:
>
> var args:Array = new Array
> var ba:ByteArray = new ByteArray
>
> args[0] = 1
> args[1] = [3,4,6,7,8,8,7,6,5,4,3,3,4,5]
> ba.writeObject(args);
> ba.position = 0;
>
> var loader:URLLoader = new URLLoader();
> var request:URLRequest = new URLRequest("http://localhost:8080/byte";);
> request.method = URLRequestMethod.POST
> request.data = ba
> request.contentType = 'application/octet-stream';
> configureListeners(loader);
> loader.load(request)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to