Flex HTTPservice and POST, Sending Files?

人盡茶涼 提交于 2019-12-12 10:00:58

问题


I use a basic Post to send data to a Django server.

The data consists of a base64 encoded 640*380 PNG image dynamically created by the flex component.

<mx:HTTPService id="formSend" showBusyCursor="true" 
    useProxy="false" url="http://127.0.0.1/form/" 
    method="POST" result="formSentConfirmation(event)"    fault="formSendingFailed(event)"/>



private function sendForm(url:String, message:String, meteo:Number):void {
    formSend.url = url;
    var params:Object = { message: message, image_data: getEncodedImage() }; 
    snapButton.label = "sending ...";
    formSend.send(params);
}

On the server side i can see that the data is in the request.POST not in request.FILES. That means the image is not send as a File with multiencode HTTP.

  1. Will i get into trouble on a real server ? since the limit is 200k for urlencoded POST var.

  2. How to make HTTPservice send the data as a file?

  3. Any other solutions?

Thanks


回答1:


  1. Probably, yes. It depends whether you impose a hard limit on the the file size and how the destination page handles the request.

  2. I don't believe it's actually possible at the moment.

  3. Read this. FileReference is the recommended way of uploading files.




回答2:


Found something interesting than we can dig on it. Use this:

var urlLoader:URLLoader = new URLLoader();
    urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
    urlLoader.data = _img.data;
    urlLoader.addEventListener(Event.COMPLETE,LoadedComplete);

    var request:URLRequest = new URLRequest("www.url.com?toto=toto");
    request.method = URLRequestMethod.POST
    request.contentType = "multipart/form-data";
    request.data = _img.data;
    request.requestHeaders = new Array(new URLRequestHeader("toto", "toto"));

    urlLoader.load(request);

Well with that i get something in C# server side the request content length is not empty and i got toto in the params and in the header, one problem in files collection there are no files sent ... where are the sent bytes ???



来源:https://stackoverflow.com/questions/365376/flex-httpservice-and-post-sending-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!