upload a zip file using HTTP POST via actionscript 3.0

前端 未结 1 874
抹茶落季
抹茶落季 2021-01-21 10:16

I have a zip file that is created using drag and drop on a view in my desktop Flex 4.6 app.

This triggers a service that will automatically upload the zip file.

1条回答
  •  南方客
    南方客 (楼主)
    2021-01-21 11:18

    Embarrassing but I found my answer 42 mins after I posted the question.

    A little bit of a rubber duck problem solving going on here.

    http://www.codinghorror.com/blog/2012/03/rubber-duck-problem-solving.html

    Short answer: Use File class and specifically the method upload which is extended from the FileReference class.

    Long answer:

            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]");
    

    0 讨论(0)
提交回复
热议问题