nsurlsessionuploadtask

Upload file with NSURLSessionUploadTask in back ground

旧时模样 提交于 2019-12-04 14:08:03
i am uploading multiple files using NSURLSessionUploadTask. I want to run same process in back ground and it works fine for current file. App is not suspended until current file got uploaded successfully. Now, when second files comes to upload, it not start uploading process until i again launch or app became active. Uploading is not falling in between thats good. Is there any way to start next uploading process when first finishes. Second uploading is start also in back ground but that works upto 3 min from app goes in back ground. Here i shows my code: AppDelegate.h @property (nonatomic,

Why does NSURLSession uploadTaskWithRequest:fromData: fail to upload to php server?

巧了我就是萌 提交于 2019-12-04 12:47:55
The php code works fine. Ive uploaded files from a html form on the same server. The files uploaded ranged from 40K to 2.0M so its not size. File uploads is activated on the server running PHP 5.3 I found many posts such as this one (without an answer yet): https://stackoverflow.com/questions/19710388/using-nsurlsession-to-upload-an-image . This one uses uploadTaskWithRequest:fromFile: instead of fromData: NSURLSession make sure Upload worked This is NSURLSessionDataTask instead of uploadTaskWithRequest: No data receiving with NSURLSession And some posts that seem to say uploadTaskWithRequest

NSURLSession, upload task - Get actual bytes transferred

三世轮回 提交于 2019-12-04 07:30:56
I was getting bug reports that my iOS app failed upload of images on slow connections. While my timeout probably wasn't high enough, there was another issue. I found that upload progress quickly went to 100% even though I could see in Charles that bytes were still being transferred. I use the following method of NSURLSession: - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(NSData *)bodyData completionHandler:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler and implement the following delegate method to receive progress

Background Upload With Stream Request Using NSUrlSession in iOS8

删除回忆录丶 提交于 2019-12-04 02:20:18
问题 Previously in iOS7 when we try to upload with stream request in background we get following exception Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks in background sessions must be from a file' But in iOS8 there is no exception when we try to upload with stream in background. Now my question is 1) Is backgourd upload with uploadTaskWithStreamedRequest: allowed in iOS8? 2) In iOS8 i am using background NSURLConfiguration with uploadTaskWithStreamedRequest

unable to upload file using NSURLSession multi-part form data in iOS

被刻印的时光 ゝ 提交于 2019-12-04 00:04:11
I am trying to upload a video / image file using - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL; method using multi-part form data. But somehow i am not able to upload the file and i am getting " stream ended unexpectedly " error. Requirements Upload a video / image file to server App should support background uploads (Continue the upload process even after app goes into background) Server expects the data to be sent using multi-part form data. Methods / API's used to achieve this NSURLSession background session API (Complete code listed

Convert NSURLConnection to NSURLSessionUploadTask example

北战南征 提交于 2019-12-02 01:36:01
Hi everyone and thanks in advance for any help providing in understanding in how to convert some NSURLConnection code into the newer NSURLSession. What I am trying to do is to make a POST request to a server, and send a photo base 64 encoded for the key "photo". Below I have an working example written in NSURLConnection and I will like to convert it into NSURLSession. As I read on the apple documentation from what I understood I should use a Data tasks because in my case it is an image and if it is a larger transfer like a video the I should use Upload tasks. Regarding the upload task I have

Background Upload With Stream Request Using NSUrlSession in iOS8

让人想犯罪 __ 提交于 2019-12-01 13:42:05
Previously in iOS7 when we try to upload with stream request in background we get following exception Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks in background sessions must be from a file' But in iOS8 there is no exception when we try to upload with stream in background. Now my question is 1) Is backgourd upload with uploadTaskWithStreamedRequest: allowed in iOS8? 2) In iOS8 i am using background NSURLConfiguration with uploadTaskWithStreamedRequest . I am using -(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task needNewBodyStream:

Uploading file using NSURLSessionUploadTask to PHP server

大憨熊 提交于 2019-12-01 13:17:17
I have a video upload system in an iOS app using NSURLSessionUploadTask . The video file is saved to an NSURL so I am using the following code in my upload method: request.HTTPMethod = @"POST"; [request addValue:@"file" forHTTPHeaderField:@"fileName"]; // Create upload task NSURLSessionUploadTask *task = [session uploadTaskWithRequest:request fromFile:filePath completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if(!error) { // handle success } else { // handle error } }]; // Run the task [task resume]; I have a PHP server (using Laravel) running under nginx to handle

Uploading file using NSURLSessionUploadTask to PHP server

假如想象 提交于 2019-12-01 11:41:51
问题 I have a video upload system in an iOS app using NSURLSessionUploadTask . The video file is saved to an NSURL so I am using the following code in my upload method: request.HTTPMethod = @"POST"; [request addValue:@"file" forHTTPHeaderField:@"fileName"]; // Create upload task NSURLSessionUploadTask *task = [session uploadTaskWithRequest:request fromFile:filePath completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if(!error) { // handle success } else { // handle error }

Upload image from iOS to PHP

南楼画角 提交于 2019-11-29 12:58:15
I'm trying to upload an image from my iOS App to my web server via PHP. Here is the following code: -(void)uploadImage { NSData *imageData = UIImageJPEGRepresentation(image, 0.8); //1 NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; //2 NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil]; NSString *urlString = @"http://mywebserver.com/script.php"; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]