nsurlsession

URLSession dataTask method returns 0 bytes of data

时光毁灭记忆、已成空白 提交于 2021-02-10 16:14:07
问题 I am using URLSession's dataTask method with a completion handler. The error in response is nil, but the data object returns something, it returns 0 bytes of data. I was using Alamofire library firstly, I thought there is something wrong with it because I started using newer version so I stated using my own implementation of Alamofire just so I don't have to rewrite all the calls I already have in my app. It still returns 0 bytes of data. When I use the same URL in the Playground with a

URLSession dataTask method returns 0 bytes of data

限于喜欢 提交于 2021-02-10 16:08:24
问题 I am using URLSession's dataTask method with a completion handler. The error in response is nil, but the data object returns something, it returns 0 bytes of data. I was using Alamofire library firstly, I thought there is something wrong with it because I started using newer version so I stated using my own implementation of Alamofire just so I don't have to rewrite all the calls I already have in my app. It still returns 0 bytes of data. When I use the same URL in the Playground with a

Background upload with share extension

北慕城南 提交于 2021-02-07 11:57:16
问题 I created an macOS ShareExtension which I want to use to upload pictures. I'm still testing this so any requests will be sent to https://beeceptor.com. The share extension works fine and it shows up in Preview, once I run it: I add some text and hit "Post" But the image is then not uploaded. This is my code that initiates the background upload: let sc_uploadURL = "https://xyz.free.beeceptor.com/api/posts" // https://beeceptor.com/console/xyz override func didSelectPost() { // This is called

NSURLSession didFinishDownloadingToURL temporary downloaded file not found

拟墨画扇 提交于 2021-02-07 05:58:19
问题 I'm having a strange issue with NSURLSession on the delegate method didFinishDownloadingToURL. First thing I'm doing is check if the temporary downloaded file exist: - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location { if (![[NSFileManager defaultManager] fileExistsAtPath: [location path]]) { NSLog(@"Error. File not found"); return; // is giving error when the app is wake up by the system } ... } It

Using system proxy in NSURLSession - unable to get challenge for setting credentials

泪湿孤枕 提交于 2021-02-07 04:28:47
问题 I've got system proxy configuration which include user credentials (name+password), and I'd like to use it with my NSURLSession object to send http messages in macOS or iOS applications. From connectionProxyDictionary documentation, I haven't set this value to get what I need : The default value is NULL, which means that tasks use the default system settings` My http message goes through the server. However, it appears that the packet doesn't have Proxy-Authorization and I get Cache Access

NSURLSession with background configuration and app killed by user

时间秒杀一切 提交于 2021-01-29 02:35:57
问题 This is the scenario: NSURLSession with background Configuration Download or upload task start with Bad or No Internet Connection. User close the App. If iOS get Internet Connection will star session task. However, With task still waiting for Internet. User kills the App System cancel all pending tasks The Question It is possible to know when the user opens the app again that the tasks were cancelled? If yes, where? This Answer says yes, it is possible, but I can not get any callback

URLSession delegate function totalBytesExpectedToWrite always return -1

廉价感情. 提交于 2021-01-27 19:35:51
问题 I have created URLSession for downloading a file, File is being downloaded correctly no problem with that. I want to show the percentage count of remain bytes, but the delegate function: -(void) URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite and its parameter totalBytesExpectedToWrite always returns -1. All thing

urlSession download from remote url fail - CFNetworkDownload_gn6wzc.tmp appeared

自作多情 提交于 2020-12-15 04:56:40
问题 I was trying to download file from remote url using urlSession . But when the download is completed an unexpected file appeared named CFNetworkDownload_gn6wzc.tmp then i cannot open that file using uidocumentinteractioncontroller. What is that file? how to fix this issue. Thank for reply. Here is message Your location is file:///Users/pisal/Library/Developer/CoreSimulator/Devices/26089E37-D4EA-49E5-8D45-BB7D9C52087D/data/Containers/Data/Application/767E966E-5954-41BA-B003-90E2D27C5558/Library