Asynchronous Audio file upload with iOS

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 10:24:35

You absolutely have to use ASIHttpRequest.

It is astoundingly easy - it's the most popular library on all of iOS.

Just select the "asynchronous" mode.

It is almost impossibly easy to use. Basically just type in the URL.

http://allseeing-i.com/ASIHTTPRequest/How-to-use

Enjoy!


It's stunning news that Ben no longer does ASIHttpRequest !

You can read all about it here:

http://allseeing-i.com/[request_release];

The NSURLConnection will allow you to upload the file asynchronously as well. There are delegate methods that will be called you on your class . Use the NSMutableURLRequest to create your upload request the follow the following guide.

URL Loading System Programming Guide

It's 2015. iOS 9.1 was just released. AFNetworking has become the most popular library for handling HTTP requests. It supports asynchronous file uploads. Here's an example:

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];

NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (error) {
        NSLog(@"Error: %@", error);
    } else {
        NSLog(@"Success: %@ %@", response, responseObject);
    }
}];
[uploadTask resume];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!