Sunday, 15 March 2015

ios - How Do You Change AFNetworking Request's Temporary FilePath -


I'm trying to migrate our ASIHTTPRequest code for AFNetworking. POST I'm fine with requests, but I'm having problems with download requests I I can not set the temporary file path to the content to download ASIHTTPRequest I could such a code:

  // Create the file path NSString * FilePath = [cachePath stringByAppendingPathComponent: package.fileName]; NSString * tempFile = [tempPath stringBiPetting PathCompany: package.fileName]; [DownloadRequest settimefiledownloadpath: tempFile]; [DownloadContact Download DownloadDettionPath: FilePath];  

How can I use AFNetworking?

  AFURLSessionManager * urlSessionManager = [AFURLSessionManager.alloc initWithSessionConfiguration: NSURLSessionConfiguration.defaultSessionConfiguration]; NSProgress * progress = zero; NSMutableURLRequest * Request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: @ "http: //your.remote.file"]]; NSURLSessionDownloadTask * downloadTask = [urlSessionManager downloadTaskWithRequest: Request Progress: & amp; Progress destination: ^ NSURL * (NSURL * TargetPath, NSURLResponse * response) {NSURL * targetFileUrl = [NSURL fileURLWithPath: @ "/ my / local / path" isDirectory: NO]; Return goal file URL; } CompletionHandler: ^ (NSURLResponse * reaction, NSURL * FilePath, NSError * error) {if (error) {// download an error has occurred or programmatic canceled} else unscathed {// download}}]; [Download Task Resume];  

Temporary files are managed by Air Force Networking, usually they hide hidden files inside your document diary.


No comments:

Post a Comment