我正在录制语音并将其保存到iphone文件夹中,但我想将其上传到服务器,那么如何执行此操作?
NSString * path = [NSString stringWithFormat:@"%@/Documents/%@_%@_%@_%@.wav", NSHomeDirectory(), patient.firstName, patient.lastName, patient.transactionId, type];
其中路径是 asset.path
if (assetIndex < ([assets count]-1)) {
while (assetIndex < ([assets count]-1)) {
assetIndex += 1;
Asset *asset = [assets objectAtIndex:assetIndex];
NSData *data = [NSData dataWithContentsOfFile:asset.path];
}
Use ASIHttp请求 http://allseeing-i.com/ASIHTTPRequest/ and jsonKit https://github.com/johnezang/JSONKit
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:kServerURLString]];
[request setData:imageData
withFileName:@"name.png"
andContentType:@"image/png"
forKey:@"file1"];
[request setPostValue:@"yourJson" forKey:@"yourKey"];
[request startSynchronous];
NSError *localError = [request error];
NSDictionary *responseDictionary = nil;
if(!localError){
responseDictionary = [[request responseString] objectFromJSONString];
NSLog(@"ResponseDict:%@",[responseDictionary description]);
}else{
NSLog(@"Error:%@",[localError description]);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)