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:

143 questions
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
  • 22,792
  • 13
  • 59
  • 99
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
  • 48,613
  • 43
  • 209
  • 344
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
  • 687
  • 1
  • 7
  • 23
0
votes
1 answer

NSURLSession , handleEventsForBackgroundURLSession, not called in the foreground?

Working on an app that does background uploads, using NSURLSession backgroundSessionConfigurationWithIdentifier And getting the handleEventsForBackgroundURLSession call back in app delegate properly when the app is not in the foreground. My…
Huang
  • 1,345
  • 2
  • 11
  • 27
0
votes
1 answer

How can I POST parameters by using NSURLSessionUploadTask from iOS background?

I would like to send a POST massage with parameters by using NSURLSessionUploadTask from iOS(later than iOS7) background then take out parameters by using $_POST['parameter'] at my .php. I knew that I have to use "uploadTaskWithRequest: fromFile:"…
0
votes
1 answer

NSURLSession: background crash because upload delegates aren't called

I have been trying to use the background upload of NSURLSession, but occasionally I get this crash Sep 25 10:01:48 ipad backboardd[29] : MyApp[11829] has active assertions beyond permitted time: {(
Leonardo
  • 1,604
  • 18
  • 25
0
votes
1 answer

How to upload in ios app extension

How to upload using AFNetworking in ios app extension? apple's example uses NSURLSession, can you explain to me how this works? - (void)didSelectPost { NSExtensionItem *imageItem = [self.extensionContext.inputItems lastObject]; // Verify that we…
0
votes
2 answers

Background Uploading Task

I have been stucked in this from last week. But I did not get the solution. I want to access all photos from camera roll and want to save all photos on remote server with the help of NSURLSessionUploadTask. For this I am using following code: …
Rox
  • 799
  • 10
  • 31
0
votes
0 answers

bodyrequest of NSURLSessionUploadTask and multipart?

Do I need multipart as content_type if I am uploading a simple jpeg image using NSURLSessionUploadTask? NSData *picture1 = UIImageJPEGRepresentation([self.imagesArray firstObject], 0.5); NSData *postbody = picture1; NSURLSessionUploadTask *task =…
0
votes
0 answers

NSURLSessionUploadTask doesn't send the whole file

I came into an issue trying to send files with NSURLSessionUploadTask to a custom REST service. The problem is that the file seems to get transferred up to an arbitrary size, and then the task stops without any error…
micamoita
  • 450
  • 2
  • 14
0
votes
2 answers

Checking which kind of NSURLSessionTask occurred

I seem to be running into trouble. For some reason, If I try to check the class type of my NSURLSessionTask objects, it doesn't work at all. If I check their taskDescription properties, this works of course if I set them before initiating the task.…
0
votes
1 answer

Server receives no data from NSURLSessionUploadTask

I'm trying to upload a file via a multipart request using NSURLSessionUploadTask via AFNetworking. The request executes and receives a response from the server, but the server is not receiving the data in the form. iOS code NSString *urlString =…
1 2 3
9
10