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
0 answers

NSURLSession Background task stops while clicking the home button?

I have develop a HTTP module for making upload download request using URLSession Background sessions. The HTTP module work in Serialize mode as specified in URLSession doc by passing nil to queue. On download complete…
0
votes
0 answers

How can I cancel an uploadTask with no memory leaks?

I am trying to upload image on server, the request is working perfectly but there is a problem with memory. So when I upload the image and get success there is no memory leaks but when I try to cancel this upload task memory is increasing. How can I…
0
votes
1 answer

Swift: How to deinitialize a URLSession when other URLSession is initialized?

I have a URLSessionDataDelegate to upload a picture to a server and the following is one part of it. The URLSession is initialized immediately when I select an image to be uploaded. But if the user taps on the Upload button and if there is no…
Ananth
  • 31
  • 1
  • 4
0
votes
2 answers

URLSession background upload task keeps resetting

I am experiencing some weird behaviour when using an uploadTask for a URLSessionConfiguration.background. My custom delegate is implementing all of the delegate methods that belong to URLSessionDelegate, URLSessionTaskDelegate, and…
0
votes
1 answer

Swift create local file, append other local file for use with NSURLSession.uploadTask

I'm working with an API that accepts video uploads using multi-part form data. I would like to use an NSURLSession.uploadTask (plus it's delegates) for handling the upload. My problem is that I need to alter the local video file to work with the…
Fred Faust
  • 6,696
  • 4
  • 32
  • 55
0
votes
0 answers

OneDrive resumable upload in iOS

I'm having issue with resumable upload, using URLSession in iOS. Everything works, except the resumable upload. The session upload creation works, I've got my uploadUrl back, so I simply start an URLSessionUploadTask: let url = URL(string:…
0
votes
1 answer

Why does NSURLSessionUploadTask to PHP endpoint with basic authentication send data twice?

I am using an NSURLSessionUploadTask via an NSURLSession on macOS 10.12 Sierra with a custom delegate to upload a local file to an Apache server with a PHP script that requests basic authentication. It works except that the upload task appears to…
Jon
  • 1,469
  • 1
  • 14
  • 23
0
votes
1 answer

NSURLSessionUploadTask originalRequest httpBody is Null

I am using NSURLSessionUploadTask to upload an image. The upload works. The image is successfully posted to my server. This is the method that is called creates a new NSURLSessionUploadTask. The NSData is the image in NSData format, and the…
0
votes
2 answers

NSURLSessionUploadTask not uploading image using POST

I have the following android code which works perfectly: DefaultHttpClient client = new DefaultHttpClient(UploadPostActivity.this); String s = "http://dacaea28.ngrok.io/my-site/multipart.php"; URL url = new URL(s); String filepath =…
java_doctor_101
  • 3,287
  • 4
  • 46
  • 78
0
votes
1 answer

ios - NSURLSession with dataTaskWithRequest fires only when app launch, not while the app is not running

As described in the title, I can reply as a text when remote notification comes. My http request works well if I tap the home button one time, but does not work when the app is not running, it waits. When the app is launched it works too. // Please…
0
votes
2 answers

Uploading multiple images using NSURLSession

I am trying to upload an array of images the user selects . They are base64 encoded . I am getting a null response from the server . Here is my code below. for (PHAsset *asset in assets) { [manager requestImageForAsset:asset …
0
votes
2 answers

NSURLSessionUploadTask example in objective-c?

Hi I'm using NSURLSessionDataTask in app to for background http call as follows, NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { But, I've 2…
Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68
0
votes
0 answers

nsurlsession post label.text value to php server execute and return a JSON value

I need to properly handle a label in my applicaiton flow. How can I do this? The steps are INPUT: plain text label convert to lower-case remove spaces send to PHP server assign to a $value in SQL submit request to the server's data base OUTPUT:…
0
votes
1 answer

Using NSURLSessionUploadTask fromFile, how to link the HTML input name with the file being uploaded?

I am wanting to upload a file to a server from an iOS device. I want to use the NSURLSessionUploadTask and I want the upload to get the content of the file being uploaded from a file. The server is expecting to receive a file called…
0
votes
2 answers

Multipart form upload in ios, How is it done?

I have to choose images or videos from the iPhone library and upload those selected images and videos to the server. I looked for the multipart form upload but could not get the necessary information. I have the following JSON structure to…