Retrieve Flash file post in ASP.NET

Posted by Quandary on Stack Overflow See other posts from Stack Overflow or by Quandary
Published on 2010-03-25T08:40:17Z Indexed on 2010/03/25 8:43 UTC
Read the original article Hit count: 423

Filed under:
|
|
|
|

Question: In ASP.NET, I retrieve a JPEG-file as Flash post data like this

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
    context.Response.ContentType = "text/plain"
    ' Retrieve a bytearray from the post buffer
    Dim myBuffer As Byte() = context.Request.BinaryRead(Convert.ToInt32(context.Request.InputStream.Length))
    System.IO.File.WriteAllBytes("c:\temp\test.jpg", myBuffer)
End Sub

In Flash, I send it to an asp.net handler like this

var jpgSource:BitmapData = cPrint.TakeSnapshot(MovieClip(cGlobals.ccPlanZoomView));
        var bmpThisBitmap:Bitmap = new Bitmap(jpgSource);

        var nQuality:Number = 100;
        var jpgEncoder:JPGEncoder = new JPGEncoder(nQuality);
        var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);

        var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");

        // Make sure to use the correct path to jpg_encoder_download.php
        var strFileName:String="test.jpg";
        var jpgURLRequest:URLRequest = new URLRequest("http://localhost/raumplaner_new/raumplaner_new/cgi-bin/SavePDF.ashx");

        //var scriptVars:URLVariables = new URLVariables();
        //scriptVars.fn = strFileName;

        //var myarr:Array= new Array();
        //myarr.push(jpgStream);
        //scriptVars.Files = myarr;

        jpgURLRequest.requestHeaders.push(header);
        jpgURLRequest.method = URLRequestMethod.POST;

        //jpgURLRequest.data = scriptVars;
        jpgURLRequest.data = jpgStream;

        var loader:URLLoader = new URLLoader();
        loader.dataFormat = URLLoaderDataFormat.BINARY;
        loader.load(jpgURLRequest);

It works but I want to send a few additional variables along, via scriptVars (commented out here). How do I retrieve the JPEG file in that case ? Because if I use parameters, there is no more BinaryRead... Aspecially, how would I read an array of jpeg files (several files) ?

© Stack Overflow or respective owner

Related posts about flash

Related posts about as3