Re: How to read a jpg bytearray from a Flash AS3 file
[EMAIL PROTECTED] wrote: Thanks! I'm using form = cgi.FieldStorage(). When I print out the contents of form, I get this: FieldStorage(None, None, '\xff\xd8\xff\xe0\x00\x10JFIF \x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb \x00\x84\x00\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c \x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f \x11\x11\x13\x16\x1c\x17\x13\x14\x1a\x15\x11\x11\x18!\x18\x1a\x1d\x1d \x1f\x1f\x1f\x13\x17$\x1e$\x1c\x1e\x1f\x1e \x01\x05\x05\x05\x07\x06\x07\x0e\x08\x08\x0e\x1e\x14\x11\x14\x1e\x1e \x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e \x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e \x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\xff\. Which is obviously the binary data of the image I want. How do I access this data? I'm used to getting it like this: name = form['name'].value But I don't think this will work in this case. TIA. What led you to ask that here, instead of taking 60 seconds to load cgi.py in an editor and search for the FieldStorage class? -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read a jpg bytearray from a Flash AS3 file
Thanks! I'm using form = cgi.FieldStorage(). When I print out the contents of form, I get this: FieldStorage(None, None, '\xff\xd8\xff\xe0\x00\x10JFIF \x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb \x00\x84\x00\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c \x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f \x11\x11\x13\x16\x1c\x17\x13\x14\x1a\x15\x11\x11\x18!\x18\x1a\x1d\x1d \x1f\x1f\x1f\x13\x17$\x1e$\x1c\x1e\x1f\x1e \x01\x05\x05\x05\x07\x06\x07\x0e\x08\x08\x0e\x1e\x14\x11\x14\x1e\x1e \x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e \x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e \x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\xff\. Which is obviously the binary data of the image I want. How do I access this data? I'm used to getting it like this: name = form['name'].value But I don't think this will work in this case. TIA. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read a jpg bytearray from a Flash AS3 file
[EMAIL PROTECTED] wrote: I'm trying to save an image from a Flash AS3 to my server as a jpg file. I found some PHP code to do this, but I want to do this in Python. I'm not quite sure how to convert the following code to Python. It's mainly the $GLOBALS[HTTP_RAW_POST_DATA] part I don't know how to convert. depends on what framework you're using. if you're using plain CGI, you should be able to read the posted data from sys.stdin: import sys im = sys.stdin.read() f = open(name, 'wb') f.write(jpg) f.close() to make your code a bit more robust, you may want to check the content-length before doing the read, e.g. import os if os.environ.get(REQUEST_METHOD) != POST: ... report invalid request ... bytes = int(os.environ.get(CONTENT_LENGTH, 0)) if bytes MAX_REQUEST_SIZE: ... report request too large ... im = sys.stdin.read(bytes) to deal with query parameters etc, see http://docs.python.org/lib/module-cgi.html /F -- http://mail.python.org/mailman/listinfo/python-list
How to read a jpg bytearray from a Flash AS3 file
I'm trying to save an image from a Flash AS3 to my server as a jpg file. I found some PHP code to do this, but I want to do this in Python. I'm not quite sure how to convert the following code to Python. It's mainly the $GLOBALS[HTTP_RAW_POST_DATA] part I don't know how to convert. ?php if ( isset ( $GLOBALS[HTTP_RAW_POST_DATA] )) { // get bytearray $im = $GLOBALS[HTTP_RAW_POST_DATA]; // save image $f = fopen($_GET['name'], 'wb'); fwrite($f, $jpg); fclose($f); } else echo 'An error occured.'; ? source: http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read a jpg bytearray from a Flash AS3 file
On 26 Sep., 08:47, [EMAIL PROTECTED] wrote: I'm trying to save an image from a Flash AS3 to my server as a jpg file. I found some PHP code to do this, but I want to do this in Python. I'd expect you use AS3 to save the image file ( just looking at Adobes AS3 docs on how this works ) and load it with PIL if you want to post- process it in Python: http://www.pythonware.com/products/pil/ -- http://mail.python.org/mailman/listinfo/python-list