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 , handleEventsForBackgroundURLSession, not called in the foreground?

Working on an app that does background uploads, using NSURLSession backgroundSessionConfigurationWithIdentifier And getting the handleEventsForBackgroundURLSession call back in app delegate properly when the app is not in the foreground. My…
Huang
  • 1,355
  • 2
  • 11
  • 28
0
votes
1 answer

How can I POST parameters by using NSURLSessionUploadTask from iOS background?

I would like to send a POST massage with parameters by using NSURLSessionUploadTask from iOS(later than iOS7) background then take out parameters by using $_POST['parameter'] at my .php. I knew that I have to use "uploadTaskWithRequest: fromFile:"…
0
votes
1 answer

NSURLSession: background crash because upload delegates aren't called

I have been trying to use the background upload of NSURLSession, but occasionally I get this crash Sep 25 10:01:48 ipad backboardd[29] : MyApp[11829] has active assertions beyond permitted time: {(
Leonardo
  • 1,740
  • 18
  • 27
0
votes
1 answer

How to upload in ios app extension

How to upload using AFNetworking in ios app extension? apple's example uses NSURLSession, can you explain to me how this works? - (void)didSelectPost { NSExtensionItem *imageItem = [self.extensionContext.inputItems lastObject]; // Verify that we…
0
votes
2 answers

Background Uploading Task

I have been stucked in this from last week. But I did not get the solution. I want to access all photos from camera roll and want to save all photos on remote server with the help of NSURLSessionUploadTask. For this I am using following code: …
Rox
  • 909
  • 11
  • 31
0
votes
0 answers

bodyrequest of NSURLSessionUploadTask and multipart?

Do I need multipart as content_type if I am uploading a simple jpeg image using NSURLSessionUploadTask? NSData *picture1 = UIImageJPEGRepresentation([self.imagesArray firstObject], 0.5); NSData *postbody = picture1; NSURLSessionUploadTask *task =…
0
votes
0 answers

NSURLSessionUploadTask doesn't send the whole file

I came into an issue trying to send files with NSURLSessionUploadTask to a custom REST service. The problem is that the file seems to get transferred up to an arbitrary size, and then the task stops without any error…
micamoita
  • 450
  • 2
  • 14
0
votes
2 answers

Checking which kind of NSURLSessionTask occurred

I seem to be running into trouble. For some reason, If I try to check the class type of my NSURLSessionTask objects, it doesn't work at all. If I check their taskDescription properties, this works of course if I set them before initiating the task.…
0
votes
1 answer

Server receives no data from NSURLSessionUploadTask

I'm trying to upload a file via a multipart request using NSURLSessionUploadTask via AFNetworking. The request executes and receives a response from the server, but the server is not receiving the data in the form. iOS code NSString *urlString =…
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,824
  • 18
  • 31
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,843
  • 13
  • 19
-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,852
  • 1
  • 25
  • 47
-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…
Darshan
  • 2,272
  • 3
  • 31
  • 43
1 2 3
10
11