Questions tagged [nsurlsessionuploadtask]

The NSURLSessionUploadTask class is a subclass of NSURLSessionDataTask, which in turn is a concrete subclass of NSURLSessionTask. It allows data upload to (web) servers and instances are created using NSURLSession.

The NSURLSessionUploadTask class is a subclass of NSURLSessionDataTask, which in turn is a concrete subclass of NSURLSessionTask. It allows data upload to (web) servers and instances are created using NSURLSession.

The methods associated with the NSURLSessionUploadTask class are documented in NSURLSessionTask Class Reference.

Upload tasks are used for making HTTP requests that require a request body (such as POST or PUT). They behave similarly to data tasks, but you create them by calling different methods on the session that are designed to make it easier to provide the content to upload. As with data tasks, if the server provides a response, upload tasks return that response as one or more NSData objects in memory.

Note: Unlike data tasks, you can use upload tasks to upload content in the background. (For details, see URL Loading System Programming Guide.)

When you create an upload task, you provide an NSURLRequest or NSMutableURLRequest object that contains any additional headers that you might need to send alongside the upload, such as the content type, content disposition, and so on.

While the upload is in progress, the task calls the session delegate’s URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: method periodically to provide you with status information.

When the upload phase of the request finishes, the task behaves like a data task, calling methods on the session delegate to provide you with the server’s response—headers, status code, content data, and so on.

Reference:

152 questions
0
votes
2 answers

Upload task using the NSURLSessionUploadTask causing NSURLErrorDomain error -999

I am using the NSURLSessionUploadTask to upload a file to a server. Once the task is resumed, everyone now and then it fails with the error code NSURLErrorDomain error -999 Now there is no cancel code anywhere in the app. What causes this to get…
user3570727
  • 10,163
  • 5
  • 18
  • 24
0
votes
2 answers

Why does uploadTaskWithRequest:fromData: need a data argument?

The documentation for uploadTaskWithRequest:fromData: says about its request parameter: The body stream and body data in this request object are ignored. Why is the body data ignored? Why not use it instead of requiring it to be passed separately…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
0
votes
2 answers

resuming upload of file after app crash using nsurlsession

I want to upload a file to a server using NSURLSession. Cases Are: 1. It should resume uploading a file to the server from where it stopped because of app crash. 2. It should handle background upload as well.
Abhishek
  • 184
  • 12
0
votes
1 answer

Issue with NSURLSession and Content-Type

I am trying to upload a photo to a webservice, and I am using the following code: NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:imageToUpload], 0.5); // 1 NSURLSessionConfiguration *config = [NSURLSessionConfiguration…
Sep
  • 79
  • 1
  • 1
  • 8
0
votes
1 answer

NSURLSessionUploadTask (1) uploads data, (2) hangs for ~200s, (3) repeats

Here's where I am so far with NSURLSessionUploadTask: iOS application starts an NSURLSessionUploadTask using POST server receives HTTP POST request server reads content of the request so data is uploaded iOS application calls …
drbobdugan
  • 443
  • 5
  • 12
0
votes
1 answer

How do I know if NSURLSessionUploadTask is working when application is suspended?

When my application is running in the foreground I see periodic calls to: NSURLSessionTaskDelegate -> URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: When my application moves to the background and is suspended, calls to…
drbobdugan
  • 443
  • 5
  • 12
0
votes
0 answers

NSURLSessionUploadTask is not calling delegate method with NSURLSessionConfiguration backgroundSessionConfiguration

I am trying upload image using backgroundSessionConfiguration and NSURLSessionUploadTask to keep live upload process in application background mode. But when i use backgroundSessionConfiguration, NSURLSessionUploadTask is not calling delegate method…
Nitin
  • 7,455
  • 2
  • 32
  • 51
0
votes
2 answers

NSURLSessionUploadTask Background Session - File Upload with some parameters

On the server side is a PHP web service that accepts post parameters userid, authenticationKey, some title, some comments and a file I am recording an audio on the iPhone and uploading to this service. The code works fine if I use…
0
votes
1 answer

NSURLSession Delegates split across classes - NSURLSession, NSURLUploadTask, NSURLDownloadTask

I'm in the process of creating an upload/download media feature for my app. I had the queue working fine for uploads but when I added downloads and the requisite download delegates the upload delegate was called event though the task was to…
0
votes
1 answer

Get server response from NSURLSessionUploadTask using custom delegate

I would like to upload an image to a server by using NSURLSessionUploadTask, which I have already accomplished by using a custom delegate let task = NSURLSession( configuration: NSURLSessionConfiguration.defaultSessionConfiguration(), …
Jojodmo
  • 23,357
  • 13
  • 65
  • 107
0
votes
1 answer

Background task execution is not working as expected

I have a requirement to make an web-service call up on tapping actionable buttons from the Remote notification. On the Remote notification, we have two buttons "Details" and "Fetch". "Fetch" is a background action (Activation Mode =…
0
votes
0 answers

NSURLSession uploading chunks in background

I have a large video to upload like 3GB 4GB in size. And I need to use NSURLSessionUploadTask to upload it in background. If I try uploading this single file then it uploads fine but pause/resume in this case not works properly. I pause somewhere…
0
votes
0 answers

NSURLSessionUploadTask in background session failing with error code -997 when app goes to background

I have an NSURLSessionUploadTask running in background session. It is a POST with a small data and receives a large response from server. It works fine when the app is in foreground. However, as soon as I put the app in background, I get a call to…
sixthcent
  • 1,150
  • 7
  • 6
0
votes
0 answers

Re-use NSURLUploadTask

I have the following code to upload a file: self.uploadManager = [[AFURLSessionManager alloc] initWithSessionConfiguration:lSessionConfiguration]; self.uploadManager.responseSerializer = [AFHTTPResponseSerializer serializer]; NSMutableURLRequest…
Raptor
  • 53,206
  • 45
  • 230
  • 366
0
votes
0 answers

Send data and parameter to server

I have this code here that send a data to my server, this code works very well: NSString *imagepath = [[self applicationDocumentsDirectory].path stringByAppendingPathComponent:@"ProgrammingWithObjectiveC.pdf"]; NSURL *outputFileURL = [NSURL…
LettersBa
  • 747
  • 1
  • 8
  • 27