nsurlsessionuploadtask

unable to upload file using NSURLSession multi-part form data in iOS

走远了吗. 提交于 2019-12-09 14:27:37
问题 I am trying to upload a video / image file using - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL; method using multi-part form data. But somehow i am not able to upload the file and i am getting " stream ended unexpectedly " error. Requirements Upload a video / image file to server App should support background uploads (Continue the upload process even after app goes into background) Server expects the data to be sent using multi-part form

NSURLSessionUploadTask how to read server response

允我心安 提交于 2019-12-08 15:00:32
问题 I am using NSURLSessionUploadTask to upload a file. Here are some parts of my code not complete let session:NSURLSession = NSURLSession(configuration: config, delegate: self, delegateQueue: NSOperationQueue .mainQueue()) let sessionTask:NSURLSessionUploadTask = session.uploadTaskWithStreamedRequest(request But the problem is I am unable to get the JSON response the server sends back. The following delegate also not firing but other delegates are firing func URLSession(session: NSURLSession,

Issue while uploading Image

大憨熊 提交于 2019-12-08 00:44:25
问题 Step 1 : here I am creating the Request NSMutableURLRequest *request1 = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[NSString stringWithFormat:@"%@%@", API_MAIN_URL, IMAGE_UPLOAD] parameters:param constructingBodyWithBlock:^(id formData) { [formData appendPartWithFileURL:[NSURL fileURLWithPath:strImagePath] name:@"sendimage" fileName:[strImagePath lastPathComponent] mimeType:@"image/png" error:nil]; } error:nil]; [request1 setValue:authToken

NSURLSessionUploadTask get response data

折月煮酒 提交于 2019-12-07 23:03:28
问题 I have some misunderstanding in using NSURLSession framework, that's why I decided to write small app from scratch without AFFramework/Alamofire. I have an API that requires following steps to upload file: POST file data Get response (JSON) Post some json fields to api/save I have a background session with such config: let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("myBackground") let session = NSURLSession(configuration: configuration, delegate:

Pause,Resume,Cancel Upload Task Using NSURLSession UploadTask

对着背影说爱祢 提交于 2019-12-06 23:37:33
问题 I am developing an app to upload multiple files using NSURLSession, right now my files are successfully uploaded. But now what i want to achieve is to pause,resume and cancel the uploads just like we do in download tasks. Is it possible.? Any help would be appreciated. Thnx 回答1: I have studied alot but could find nothing .After i tried this on my code assuming this as a download task ,I came to know that we can "pause , resume" upload tasks as well using NSURLSession just we do in downloading

Upload file with NSURLSessionUploadTask in back ground

二次信任 提交于 2019-12-06 07:32:41
问题 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 not start uploading process until i again launch or app became active. Uploading is not falling in between thats good. Is there any way to start next uploading process when first finishes. Second uploading is start also in back ground but that works

Issue while uploading Image

感情迁移 提交于 2019-12-06 06:12:18
Step 1 : here I am creating the Request NSMutableURLRequest *request1 = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[NSString stringWithFormat:@"%@%@", API_MAIN_URL, IMAGE_UPLOAD] parameters:param constructingBodyWithBlock:^(id formData) { [formData appendPartWithFileURL:[NSURL fileURLWithPath:strImagePath] name:@"sendimage" fileName:[strImagePath lastPathComponent] mimeType:@"image/png" error:nil]; } error:nil]; [request1 setValue:authToken forHTTPHeaderField:@"Authorization"]; Step 2: here I am creating the Stream at given Location [

NSURLSessionUploadTask get response data

老子叫甜甜 提交于 2019-12-06 06:06:11
I have some misunderstanding in using NSURLSession framework, that's why I decided to write small app from scratch without AFFramework/Alamofire. I have an API that requires following steps to upload file: POST file data Get response (JSON) Post some json fields to api/save I have a background session with such config: let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("myBackground") let session = NSURLSession(configuration: configuration, delegate: self, delegateQueue: nil) I've implemented 2 methods: func URLSession(session: NSURLSession, dataTask:

NSURLSession, upload task - Get actual bytes transferred

心不动则不痛 提交于 2019-12-06 03:46:03
问题 I was getting bug reports that my iOS app failed upload of images on slow connections. While my timeout probably wasn't high enough, there was another issue. I found that upload progress quickly went to 100% even though I could see in Charles that bytes were still being transferred. I use the following method of NSURLSession: - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(NSData *)bodyData completionHandler:(void (^)(NSData *data, NSURLResponse *response,

Pause,Resume,Cancel Upload Task Using NSURLSession UploadTask

情到浓时终转凉″ 提交于 2019-12-05 04:06:59
I am developing an app to upload multiple files using NSURLSession, right now my files are successfully uploaded. But now what i want to achieve is to pause,resume and cancel the uploads just like we do in download tasks. Is it possible.? Any help would be appreciated. Thnx I have studied alot but could find nothing .After i tried this on my code assuming this as a download task ,I came to know that we can "pause , resume" upload tasks as well using NSURLSession just we do in downloading tasks. To pause a task simply call [yourUploadTask suspend]; to resume [yourUploadTask resume]; To cancel