开发者

Uploading Audio Files with ASIHTTPRequest

Can anyone please give me a tutorial on how to upload Audio Files onto a server using ASIHTTPRequest? I'll need to build a JSON and get the audio data into the JSON then send it to the server. If this is too vague please don't hesitate to ask for more inf开发者_如何学JAVAo.

let's say i use AVAudioRecorder class. What would i use to send that audio file to the server that is created after I record it and am ready to upload it?


You would use the ASIFormDataRequest class. See the "Sending a form POST with ASIFormDataRequest" section of this url: http://allseeing-i.com/ASIHTTPRequest/How-to-use

You may need to temporarily store the file on the phone, get the path to that file, and then sent it as a file in this class. It works with images I know, so it should work with other files as well. Your PHP script or whatever that is receiving the file will just need to know how to handle the file type.

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request setFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photo"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜