Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-26-2010, 08:45 PM   #1
Tapestes
Registered User
 
Join Date: Apr 2008
Posts: 9
Default Post file to server

I've got a .wav file on my machine. I want to upload that file (filename and file location never changes) to a url where REST is being used, but I'm having a really difficult time teasing out how this should be done. The request is supposed to make use of multi-part/form data. After uploading, the service will respond and I need to collect that data. I've got a hodgepodge of code and I just haven't made any progress.

From what I can tell a) I probably can't use upload with the POST method b) I might need to save my wav file as a bytearray, but I have no idea how to do that c) as is obvious, I'm fairly lost. Any help would be greatly appreciated.

Thanks,

Tap

Code:
function postFileAndRetrieveTranscript():void 
{ 
	var request:URLRequest = new URLRequest("my address here");
	request.method = URLRequestMethod.POST;
	request.contentType = 'multipart/form-data';
	fileToPost = File.desktopDirectory.resolvePath("recording.wav");
	fileToPost.addEventListener(Event.COMPLETE, completeHandler); 

	try 
    { 
        fileToPost.upload(request); 
    } 
    
	catch (error:Error) 
    { 
        trace("Unable to upload file.");
		fileToPost.removeEventListener(Event.COMPLETE, completeHandler);
    }
} 

function completeHandler(event:Event):void 
{ 
    trace("uploaded");
	
	var loader:URLLoader = URLLoader(event.target);
	var transcript = new URLVariables(loader.data).success;
	
	trace("transcript: " + transcript);
}
Tapestes is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:20 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.