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
48
votes
1 answer

How to get server response data in NSURLSession without completion block

I am using NSURLSession for background image uploading. And according to uploaded image my server gives me response and I do change in my app accordingly. But I can't get my server response when my app uploading image in background because there is…
user3648985
16
votes
2 answers

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

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…
14
votes
2 answers

NSURLSessionUploadTask how to read server response

I am using NSURLSessionUploadTask to upload a file. Here are some parts of my code not complete let session:NSURLSession = NSURLSession(configuration: config, delegate: self, delegateQueue: NSOperationQueue .mainQueue()) let…
10
votes
3 answers

URLSessionUploadTask getting automatically cancelled instantly

I'm having this weird issue in which a newly created URLSessionUploadTask gets cancelled instantly. I'm not sure if it's a bug with the current beta of Xcode 8. I suspect it might be a bug because the code I'm about to post ran fine exactly once. No…
Andy Ibanez
  • 11,317
  • 8
  • 63
  • 94
9
votes
2 answers

Pause,Resume,Cancel Upload Task Using NSURLSession UploadTask

I am developing an app to upload multiple files using NSURLSession, right now my files are successfully uploaded. But now what i want to achieve is to pause,resume and cancel the uploads just like we do in download tasks. Is it possible.? Any help…
7
votes
1 answer

NSURLSession background transfer not working

I’m trying to download a series of files from server to iOS app, with the intent that the download of these files happen even when the App is in the background mode. I'm using background transfer provided by NSURLSession and its series of APIs. I…
5
votes
1 answer

Implementing completion handlers for backgroundSession.uploadTask

I have (almost) successfully implemented URLSessionDelegate, URLSessionTaskDelegate, and URLSessionDataDelegate so that I can upload my objects in the background. But I'm not sure how to implement completion handlers, so that I can delete the object…
Frederik
  • 436
  • 5
  • 22
5
votes
1 answer

NSURLSession, upload task - Get actual bytes transferred

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…
5
votes
1 answer

NSURLSession background uploading huge files

I am trying to upload a large file 2GB in the background using NSURLSessionUploadTask. The service uses multipart format, so in order to upload it in the background i am creating a temporary file with the Body of the request, then i am using a…
5
votes
2 answers

Does AFNetworking V 2 support non streaming multi part background upload tasks?

A project I am working on needs to upload a video. The post API call for uploading a video needs a multipart body. The code I tried to use is included at the bottom of the question. The code works perfectly for [NSURLSessionConfiguration…
4
votes
1 answer

IOS NSURLSession Background Uploading how to upload Large Files in Background?

I want to Upload the Large Files (Videos) of 2-3 GB to Server in background with the following requirements First Method Uploading should resume if the internet Connection lost and reconnected Uploading should continue even application is in…
Fahad Rehman
  • 996
  • 8
  • 22
4
votes
2 answers

ios8: How do you upload 100s of photos in background using NSURLSession? Free space issue

How do photo apps upload EVERYTHING from the CameraRoll in the background? I have the need to upload 100s of photos in the background based on date range. My app is currently using NSURLSession with the following code (I think...) But for this to…
michael
  • 3,521
  • 4
  • 39
  • 61
4
votes
1 answer

NSURLSession background upload - need to enable background modes?

I am instantiating a NSURLSession to do several background uploads like this: sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:myIdentifier]; Everything seems to work OK for the most part, but I…
Oscar Gomez
  • 18,102
  • 12
  • 80
  • 113
4
votes
2 answers

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

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…
marciokoko
  • 4,952
  • 7
  • 46
  • 90
4
votes
2 answers

NSURLSession backgroundSession additional API call on completion

I need to upload content to AWS S3 via PUT that can be run in a background session using NSURLSessionUploadTask. So far it works great. However I need to then call my API once the upload to S3 has finished to change it's state to complete. I AWSS3…
1
2 3
9 10