C # .net equivalent to HTTP_RAW_POST_DATA?

Want to emulate php code in C #.

I want to capture raw image data published in the following Flash ActionScript:

function onSaveJPG(e:Event):void{ var myEncoder:JPGEncoder = new JPGEncoder(100); var byteArray:ByteArray = myEncoder.encode(bitmapData); var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); var saveJPG:URLRequest = new URLRequest("save.aspx"); saveJPG.requestHeaders.push(header); saveJPG.method = URLRequestMethod.POST; saveJPG.data = byteArray; var urlLoader:URLLoader = new URLLoader(); urlLoader.addEventListener(Event.COMPLETE, sendComplete); urlLoader.load(saveJPG); function sendComplete(event:Event):void{ warn.visible = true; addChild(warn); warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown); warn.buttonMode = true; } } 

On the download page of Save.aspx.cs. Here is the PHP code I'm trying to emulate -

 if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){ $jpg = $GLOBALS["HTTP_RAW_POST_DATA"]; $img = $_GET["img"]; $filename = "images/poza_". mktime(). ".jpg"; file_put_contents($filename, $jpg); } else{ echo "Encoded JPEG information not received."; } 

Any pointers and suggestions would be highly appreciated. Thanks!

+4
source share
2 answers

Something like this work for you?

 byte[] data = Request.BinaryRead(Request.TotalBytes); 
+6
source

You can receive raw HTTP message data by contacting Request.InputStream . Read from the stream and write it to a file.

EDIT: Use James's Request.BinaryRead . For writing, you can use File.WriteAllBytes(filename, data) . The $_GET equivalent in asp.net is Request.QueryString .

+3
source

All Articles