afnetworking

How can I save a html file with external resources using AFNetworking?

筅森魡賤 提交于 2019-12-08 02:15:04
问题 I would like to save a .html webpage with AFNetworking, but would also like to save the resources (such as .css files, .js files, images etc) within the webpage so that the whole webpage can be viewed offline. Is this possible with AFNetworking, and how would I do it? Could a short example be posted please? Thanks! 回答1: AFNetworking is not necessary to do this. Instead, what you want to do is use an NSURLCache subclass that supports disk cacheing (such as Peter Steinberger's fork of

Using AFNetworking to upload an Audio File

荒凉一梦 提交于 2019-12-08 01:52:35
问题 I'm trying to use the AFNetworking library to upload a file to Clypit. I've looked at their documentation here: https://github.com/AFNetworking/AFNetworking And have configured my code to upload an audio file like so: NSIndexPath *cellIndexPath = [self.tableView indexPathForCell:cell]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:cellIndexPath]; ICIRecordingCell *c = (ICIRecordingCell *)cell; NSString *fileName = c.title.text; NSURL *filePath = [NSURL fileURLWithPath:fileName

Uploading large files on iOS with AFNetworking - error Request Timeout

天涯浪子 提交于 2019-12-08 01:39:19
问题 I'm facing with the next problem. In my project, I'm using AFNetworking for all network operations. One of them is uploading video the the server. Then I'm trying to upload large video (about 100 Mb), I'm getting request timeout error. Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x15641b30 {NSErrorFailingURLStringKey= http://server.name/path , NSErrorFailingURLKey= http://server.name/path , NSLocalizedDescription=The request timed out., NSUnderlyingError

How to migrate AFHTTPClient, Afnetworking 1.0 to 2.0

北城以北 提交于 2019-12-08 00:57:47
问题 My problem is that I have a old code and I dont know how to change it. I had 1 class called API (AFHTTPClient) I have problems with 2 methods because I dont know how to put them in 2.0: This: -(void)commandWithParams:(NSMutableDictionary*)params onCompletion:(JSONResponseBlock)completionBlock { NSMutableURLRequest *apiRequest = [self multipartFormRequestWithMethod:@"POST" path:kAPIPath parameters:params constructingBodyWithBlock: ^(id formData) { //TODO: attach file if needed }];

Issue while uploading Image

大憨熊 提交于 2019-12-08 00:44:25
问题 Step 1 : here I am creating the Request NSMutableURLRequest *request1 = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[NSString stringWithFormat:@"%@%@", API_MAIN_URL, IMAGE_UPLOAD] parameters:param constructingBodyWithBlock:^(id formData) { [formData appendPartWithFileURL:[NSURL fileURLWithPath:strImagePath] name:@"sendimage" fileName:[strImagePath lastPathComponent] mimeType:@"image/png" error:nil]; } error:nil]; [request1 setValue:authToken

AFNetWorking 实现文件的下载 断点续传

China☆狼群 提交于 2019-12-07 21:13:53
最近用到了下载,网上也搜寻过下载方面的东西,没有找到太合适的关于AFNetWorking 3.x方面的断点续传的介绍或者demo,于是自己写吧。 AFURLSessionManager这个封装了上传、下载方面的相关内容,仔细阅读不难发现,这个就是对 NSURLSession 、NSURLSessionTask 进行的封装,下载、上传这些操作用到的就是NSURLSessionTask相关子类。 先说说第一种方式,就是最简单的下载,用到的方法显而易见 /** 第一种方式 */ //方法包含了下载所需的 参数 回调 很全面, 这里返回一个NSURLSessionDownloadTask对象,用于调用系统的方法: resume开始、继续下载,suspend暂停下载,cancel取消下载 - (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination

AFNetworking 3 issue

余生颓废 提交于 2019-12-07 20:27:06
问题 In AFNetworking 3 for invalid SSL certificate I used validatesCertificateChain = false , but now it seems that this field was removed and I can't make requests to my server. Here is class for requests: import UIKit import AFNetworking class ClientHTML: AFHTTPSessionManager { private static var __once: () = { () -> Void in let securityPolicy = AFSecurityPolicy(pinningMode: AFSSLPinningMode.certificate) securityPolicy.validatesDomainName = false securityPolicy.allowInvalidCertificates = true

AFNetworking with AFJSONRequestOperation and filedata never completes

人走茶凉 提交于 2019-12-07 17:31:29
问题 I'm using AFNetworking to post json data to my webservice and get a json response back. However now I also want to add multipart formdata to these POST's. If I do this (even without the parameters I added first) the completion block never fires. The progress block DOES fire and I can see that the file uploads correctly. Does anybody have any experience posting images like this with AFNetworking? I am using the latest AFNetworking source / version. This is my initial code for posting a

AFNetworking - reachability returning always -1

柔情痞子 提交于 2019-12-07 16:09:27
I use latest AFNetworking sources and the reachability doesn't work for me, it never fires reachability block and the [httpClient networkReachabilityStatus] always returns -1. SystemConfiguration/SystemConfiguration.h is included in .pch startMonitoringNetworkReachability is executed (in AFHTTPClient). iPhone 4, iOS 6.1 AFHTTPClient *httpClient = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:URL]]; [httpClient setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { NSLog(@"Internet status changed"); NSLog(@"%d", status); }]; NSMutableURLRequest *request = [httpClient

Can AFNetworking 2 store the cookies

不羁岁月 提交于 2019-12-07 15:44:56
问题 I used AFHTTPClient and seems it stored cookies in the box. So when I was logged in. and then reload my app, the cookies were in application automatically. Maybe I confused about this. But seems it works in the way I described. Now I use this code: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:path parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { } failure:^(AFHTTPRequestOperation *operation, NSError *error)