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

Resume upload task using NSURLSessionUploadTask after app is killed?

I am using the following code to upload image using NSURLSessionUploadTask NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager *manager = [[AFURLSessionManager alloc]…
2
votes
1 answer

NSURLSession task execution order

I am adding multiple tasks to a NSURLSession (background mode) , in an order. I have kept HTTPMaximumConnectionsPerHost = 1. However, I am seeing that the uploads are taken up in a random order i.e, after the 1st item may be 5th item is picked up…
tuttu47
  • 481
  • 1
  • 4
  • 19
2
votes
0 answers

Upload file with NSURLSessionUploadTask in back ground

i am uploading multiple files using NSURLSessionUploadTask. I want to run same process in back ground and it works fine for current file. App is not suspended until current file got uploaded successfully. Now, when second files comes to upload, it…
Pratik Patel
  • 1,330
  • 12
  • 18
2
votes
0 answers

NSURLSessionUploadTask request pause and resume causes 400

While app goes to background, I pause the the upload task for Amazon S3 and then resuming the same task on foreground. This causes sometimes NSURLSession's delegate method didCompleteWithError:(NSError *)error to throw 400 and error as nil and fails…
Vani
  • 424
  • 4
  • 19
2
votes
1 answer

Convert NSURLConnection to NSURLSessionUploadTask example

Hi everyone and thanks in advance for any help providing in understanding in how to convert some NSURLConnection code into the newer NSURLSession. What I am trying to do is to make a POST request to a server, and send a photo base 64 encoded for the…
2
votes
2 answers

Issue while uploading Image

Step 1: here I am creating the Request NSMutableURLRequest *request1 = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" …
2
votes
2 answers

NSURLSessionUploadTask don't upload image with parameters

I have this code below which sends an image and some text to my server: NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; self.session = [NSURLSession sessionWithConfiguration:…
LettersBa
  • 687
  • 1
  • 7
  • 23
2
votes
2 answers

Upload with Buffer iOS 7

I am trying to implement an Upload with random Data and measure the speed. For now i am generating my random NSData like this: void * bytes = malloc(""); NSData * myData = [NSData dataWithBytes:bytes length:"bytes"]; free("bytes"); But there will…
davidOhara
  • 978
  • 4
  • 16
  • 38
1
vote
0 answers

File getting corrupted if user cancels file UPLOAD on WEBDAV repository

In one of my iOS app, I'm trying to upload a file on WEBDAV repository and this is how I'm preparing things for UPLOAD - func createUploadRequest(url: String) -> URLRequest? { if let url = URL(string: url) { var request =…
Suryakant Sharma
  • 3,356
  • 1
  • 20
  • 43
1
vote
0 answers

Best place to call `completionHandler` received in `handleEventsForBackgroundURLSession` in case of uploading?

I am using URLSessionConfiguration.background for uploading and downloading content while my app is not foreground. The code that I'm using to create a background session is as below: private var session: URLSession! private override init()…
1
vote
0 answers

Xamarin- Nsurlsession UploadTask not working for iOS in background

I am having a xamarin forms application in which I need to upload image files to the server and upload should continue even when the application goes to background. I have implemented nsurlsession CreateUploadTask with multipart-form data and I am…
1
vote
0 answers

Why is there progress callback information printed when using backgroundSession to upload tasks in the background

I would like to ask a question when I was in the background with backgroundSessionConfigurationWithIdentifier upload task encountered the following problem: Background: I have a lot of uploading task (assuming that there are 200), I will create 200…
xue li
  • 11
  • 1
1
vote
0 answers

Multiple background uploads using URLSession

I'm working on an app that needs to be able to upload an array (can contain a mix of UIImage or a custom struct that contains a local file URL and some data). I've seen Operations and OperationQueues as a possible starting point but I don't know if…
1
vote
0 answers

Task parameter is nil in didCompleteWithError callback

I'm trying to upload files using NSURLSessionUploadTasks and a background NSURLSession. The problem is that when the upload completes, the URLSession:task:didCompleteWithError: callback is invoked with a nil task parameter. The session parameter is…
adienthu
  • 143
  • 1
  • 6
1
vote
1 answer

Swift3 video file upload along with one more form parameter(can be skipped from form and sent as url path)

I have searched for a long time but didn't find any good resource on how to do this. The api expects one form parameter "user_id"(for now sending its as urlpath not form parameter) and other "file" for the video file. please provide some code…
1 2
3
9 10