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

Upload image from iOS to PHP

I'm trying to upload an image from my iOS App to my web server via PHP. Here is the following code: -(void)uploadImage { NSData *imageData = UIImageJPEGRepresentation(image, 0.8); //1 NSURLSessionConfiguration *config =…
0
votes
1 answer

Crash with NSURLSessionUploadTask when trying to upload in background

In my app I try to upload some data to a server when the app enters the background. This is the code I am using: Session self.session = [self backgroundSession]; This is how my session is set up - (NSURLSession *)backgroundSession { static…
freshking
  • 1,686
  • 15
  • 26
0
votes
0 answers

IOS 7 Upload task from file to GRAILS

I'm trying to upload a file from an IOS app to a GRAILS backend using NSURLSession and NSURLSessionUploadTask. NSURL *uploadURL = [NSURL URLWithString:@"http://192.168.1.71:8080/copesmart/mobileInstance/uploadOneFile"]; NSURLRequest *request =…
-1
votes
1 answer

URLSessionTaskDelegate - delay between 100% progress and didCompleteWithError call

URLSessionTaskDelegate has two methods - didSendBodyData that called every upload progress update, and didCompleteWithError that called at the end of the file transfer. The problem is that didSendBodyData reaches 100%, and only 2-3 seconds after…
Avi Tsadok
  • 1,823
  • 13
  • 18
-1
votes
1 answer

File upload fails for files which contains semicolon (;) in filename

I'm trying to upload a file to an API with URLSessionUploadTask using method uploadTask(with request: URLRequest, fromFile fileURL: URL) -> URLSessionUploadTask Everything works perfect until file name doesn't contains semicolon. When file name…
Suryakant Sharma
  • 3,356
  • 1
  • 20
  • 43
-1
votes
1 answer

Multiple Video upload with progress

Looking for example for multiple video upload with progress view . Here i have defined steps. Open gallery and select video. select video from gallery and after compilation of selection ,create thumb image. All selected video show with thumb images…
user1374
  • 2,171
  • 2
  • 26
  • 40
-1
votes
1 answer

Multiple File Upload using uploadTaskWithRequest fromFile in background

I am trying to upload multiple images using NSURLSession .It works fine when application is running in foreground.When application enter background,uploading process stop after uploading current task.I would like to upload all the files when…
sasha
  • 273
  • 1
  • 6
  • 14
-2
votes
1 answer

Video Upload using NSURLSessionUploadTask. Error "The network connection was lost.”

I’m trying to upload a video file through service using NSURLSessionUploadTask. But getting an issue saying Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost.” But I can able to upload image file without an issue. what would…
1 2 3
9
10