How to get JSON result after file upload via actionscript

I know how to upload a file using a script action

See download the zip file using HTTP POST through ActionScript 3.0 .

The code is copied here:

var urlRequest:URLRequest = new URLRequest(PUBLISH_ZIP_FILE_URL); // set to method=POST urlRequest.method = URLRequestMethod.POST; var params:URLVariables = new URLVariables(); params['data[File][title]'] = 'Title1'; params['data[File][description]'] = 'desc'; // this is where we include those non file params and data urlRequest.data = params; // now we upload the file // this is how we set the form field expected for the file upload file.upload(urlRequest, "data[File][filename]"); 

The web application responsible for accepting the file download will return a JSON string containing data such as file size, ID number, etc.

How do I access this JSON result string in my ActionScript?

+1
source share
1 answer

From the FileReference docs, you need to add a handler to your FileReference instance for the uploadCompleteData event:

 import flash.events.*; // now we upload the file // this is how we set the form field expected for the file upload file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadCompleteDataHandler); file.upload(urlRequest, "data[File][filename]"); private function uploadCompleteDataHandler(event:DataEvent):void { trace("uploadCompleteData data: " + event.data); } 
+1
source

Source: https://habr.com/ru/post/1415033/


All Articles