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

NSURLSession limit file size to 100KB

I am unsure what is happening but I have a code that sends an image to a server running on my Mac. It works perfectly when I set the UIImageJPEGRepresentation to 0.1 quality. But anything above that (like below) will crash the print server. It seems…
0
votes
1 answer

Continue with code after URLSession.shared.uploadTask is completed

I am trying to communicate with Swift to a php-website using the command "uploadTask". The site is sending Data back, which is working well. The result from the website is stored in the variable "answer". But how can I actually use "answer" AFTER…
highii
  • 1
  • 2
0
votes
1 answer

upload file api with uploadtask in symfony 2.8

We realize that if we want to produce a multipart query that contains a video file of 15GB, it is impossible to allocate in memory the size needed for such a large amount of data, most devices have only 2 or 3GB of RAM. It is therefore absolutely…
0
votes
1 answer

Upload Image and Parameters to API with URLSession.shared.uploadTask

I am trying to solve how to upload a set of parameters and an image file to my API using swift. My code is roughly at about this point: //parameters let actualParameters = ["email": myEmail, "token": myToken, "certnbr": certnbr, "title": title,…
C. Skjerdal
  • 2,750
  • 3
  • 25
  • 50
0
votes
1 answer

NSURLSession: streaming latency spikes

We have streaming app, which essentially upload data (video chunks) on server in very tight schedule. We use http streaming to do so (via NSURLSession uploadTaskWithStreamedRequest), not websockets/direct connection. Chunk sizes are around…
IPv6
  • 405
  • 4
  • 17
0
votes
1 answer

Should I create new NSURLSessionTask after handling HTTP error?

In my Xamarin.iOS app, I want to retry an upload after a failure due to http error. But I'm not sure how to implement. I was thinking I should just keep creating a new task every time it completes with an http error? Is this the correct way to…
empo
  • 1,133
  • 5
  • 21
  • 41
0
votes
1 answer

iOS background uploads - how to verify responses received if app crashes?

When performing background uploads in iOS, is there a mechanism in place that will re-deliver upload results from the system if the app crashes while handling said results? I was hoping to see some sort of confirmation system in place telling the…
Zach
  • 3,909
  • 6
  • 25
  • 50
0
votes
1 answer

How to add Image with a NSMutableDictionary and send the NSMutableDictionary to server using POST method in iOS

I want to send image with key in a NSMutableDictionary and send all other elements of dictionary to server using post & Nsurlsession in ios using objective C
Pratik
  • 103
  • 1
  • 9
0
votes
1 answer

When trying to run a task, sending an image, getting error Code=13 "query cancelled"

I am currently using an image picker for an iOS app to get a picture from the camera role, then trying to send it to a PHP Script on a web server to save the image at the other end. When the the line of code task.resume() runs, however, this error…
0
votes
1 answer

How to hit post request with NSDictionary as parameter

I am trying to hit post type sending dictionary as parameter. Below is what i tried so far, but i think format sending is not generating correctly. Please guide, code is below: Data fetching which need to send as parameter: NSArray *routesLegsArray…
iPhone 7
  • 1,731
  • 1
  • 27
  • 63
0
votes
1 answer

How to track URLSessionTask after Alamofire retries the request

We are using Alamofire 4 and want to match URLSessionTasks to entities in a database. We first used the taskDescription field of URLSessionTask to put UUID of a database entity there, but then figured out that Alamofire creates a new task on request…
0
votes
0 answers

Upload Task and REST api in URLSession iOS

I want to upload data using REST api and uploadTask of URLSession in background.I search a lot but cannot find examples of this.I have data that is store in local database with different fields such as latitude/longitude ,images etc.Now I want to…
naf123
  • 79
  • 2
  • 7
0
votes
2 answers

Upload images to server in array form?

I need to send images data to server in array form.I need a sample code which should be accepted by server.In server our backend developers accepting like below format {"images": { "name": ["Desert.jpg", "Hydrangeas.jpg", "Koala.jpg",…
0
votes
1 answer

NSURLSessionUploadTask - specify content range

I'm using NSURLSession's uploadTaskWithRequest:FromFile: to upload a file in the background. This works, however I'd like to upload only a certain part of the file. So I am trying to get the upload task to only upload a certain range of the file.…
Amos Joshua
  • 1,601
  • 18
  • 25
0
votes
1 answer

How to upload an image file in a background session (iOS)?

I am unable to upload an image from my device's Photos in a background session. When I call [session uploadTaskWithRequest:req fromFile:nsurl] the system immediately complains by sending Failed to issue sandbox extension for file…