Hi,
I am trying to mimic the following PHP code in C#
<?php
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
// get bytearray
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
// add headers for download dialog-box
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $im;
} else echo 'An error occured.';
?>
So far I have:
public ActionResult GetPostedImage(string name)
{
var res = Response;
res.Clear();
res.Cache.SetCacheability(HttpCacheability.NoCache);
res.ContentType = "image/jpeg";
res.AppendHeader("Content-Disposition", "filename=\"" + name + "\"");
res.Write(Request.InputStream);
return View();
}
Problem is that the Request.InputStream does not contain the raw image data posted from the following Flash Actionscript:
var jpgSource:BitmapData = new BitmapData(mc_avatar.width, mc_avatar.height);
jpgSource.draw(mc_avatar);
trace(jpgSource);
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream = jpgEncoder.encode(jpgSource);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("/cms3/getpostedimage?name=bloke.jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "_self");
I am sure I am missing something really basic, so any pointers would be much appreciated.