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
1
vote
1 answer

Unable to sustain a Constant Speed while Uploading files in the background with NSURLSession

I am trying to upload some 100 images to S3 in the background with AFURLSessionManager in small batches of 10 like what is being done here- Manage the number of active tasks in a background NSURLSession I am using a shared NSURLSession and adding…
Xcoder
  • 1,762
  • 13
  • 17
1
vote
1 answer

NSURLSession resume upload video

I am uploading a video using NSURLSession, right now my video is successfully uploaded. but once wifi connection OFF, the below delegate method is executed right away. - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task…
QueueOverFlow
  • 1,336
  • 5
  • 27
  • 48
1
vote
4 answers

iOS NSURLSessionUploadTask response data

I have successfully implemented the NSURLSessionUploadTask and work in both background and foreground. But there is an issue when reading the response data. - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask…
1
vote
1 answer

NSURLSessionUploadTask does not respond to resume ios8 Beta3 (Device only)

When sending the resume method on a NSURLSessionUploadTask using a background client, NSURLSessionConfiguration:backgroundSessionConfiguration:, the process never begins. I can not reproduce on simulator, only on the device, and only on 8.0. This is…
Ryan Romanchuk
  • 10,819
  • 6
  • 37
  • 41
1
vote
0 answers

NSURLSession multiple background uploads

In my app I am creating a background session with a single identifier, (using the singleton method) that has ~50-100 upload tasks(images) when the user tries to upload their "Orders". Each Order has ~25 images to upload. I am storing the OrderID as…
0
votes
1 answer

Live Activities and Upload in Background iOS

I'm developing a new feature that allows the user to keep track of a background upload through live activities. Im using the URLSessionTaskDelegate to keep track of the task progress and it works fine when the app is in foreground, but when the app…
0
votes
0 answers

Got error when trying to upload multiple images to server using URLSession Background Session

I am uploading multiple images to server using URLSession. I am using uploadTask(with: request, fromFile: URL(fileURLWithPath: path)). While uploading i got below error every time when i am trying to upload more than 10 images. Everything goes fine…
0
votes
1 answer

How to handle URLSessiosn UploadTask ResumeData when delegate method got fired?

I was implementing an upload task using URLSession Uploadtask with the below code: lazy var urlSession = URLSession( configuration: .background(withIdentifier: "com.test.xxxxx"), delegate: self, …
Mumthezir VP
  • 6,251
  • 6
  • 28
  • 57
0
votes
0 answers

NSUrlSessionTaskDelegate DidSendBodyData totalBytesSent inaccurate

NSUrlSessionTaskDelegate DidSendBodyData totalBytesSent seems to indicate that upload progress is being reported out of order. I created a simple test with a single upload, and logged the value of totalBytesSent every time it was called. For…
Magnetic Llama
  • 154
  • 2
  • 11
0
votes
2 answers

Stream Requests Uploads getting slow in iOS Background Session from iOS 15.x

I am working on an app which uses iOS NSURLSession background session to upload the data to the S3 server. From iOS 15.x, We have observed that transfer speed has become too slow (~10 kbps). Following is the configuration, I am using Create the…
gauravs
  • 19
  • 1
  • 4
0
votes
1 answer

Background file upload - Own Cloud (iOS)

I am trying to upload file, images, videos when app is in background state to own cloud server in iOS Swift. Own cloud library has the capability to start upload through OS so that upload happens even when app is killed, but it doesn't even work for…
0
votes
0 answers

urlSession didSendBodyData reports wrong totalBytesExpectedToSend

The didSendBodyData method of URLSession delegate with uploadTask running is called with a wrong totalBytesExpectedToSend value. It seems to be about double of what it should be but not exactly. The URLSessionTask parameter contains field…
jab11
  • 867
  • 1
  • 8
  • 15
0
votes
1 answer

Resume Unfinished multipart/form-data Upload Task on App Launch after the app was killed

I'm making an app where I upload multiple Images and Videos using Alamofire 5.2. The upload might take long time because the file sizes might be big and making the user wait for upload is not what I want. So I let the user explore the app and keep…
0
votes
1 answer

Background URLSession stuck

I'm uploading a lot of files to a server using URLSession, because the uploaded files can be big I'm using URLSessionConfiguration.background so that my uploads can continue in the background. My url session is declared like…
Philou
  • 67
  • 1
  • 10
0
votes
0 answers

Swift URL Session: Progress bar increments even with Server Error [404, 500]

I have implemented a background upload task using URLSession as follow: let boundary = UUID().uuidString let configuration = URLSessionConfiguration.background(withIdentifier: "com.example.upload") let session = URLSession(configuration:…