ProgressBar While POST API call Swift 4 - ios

I'm uploading 1900 contacts on my server through a POST API call (AFNetworking). It is taking some time to get a response from the server. During the upload I want to show a progress bar to show an estimated remaining upload time, as I'm not uploading any file , I use json string to post parameters.
Please help me with this, through Google search I could not find any help regarding the upload or download API.

There are multiple answers on StackOverflow already answering your specific use case. For example have a look at this question: get progress from dataTaskWithURL in swift
For your specific use case there are also already answers using AFNetworking: AFNetworking 3.x multipart form upload
To summarize, what you want to do is to
1. calculate the total amount of data you want to upload and the
2. total amount of data you already uploaded via the URLSession delegate methods.
Then you can bind this information to your UI element, for example your UIProgressView. Make sure that your upload tasks are asynchronous in order to have a non blocking upload task and to be able to update your UI while the upload is happening. This also means that other than your upload task your code to refresh the UI should run on the main thread. You can enforce this via DispatchQueue.main.async if needed.

Related

Check if resource at NSURL exists BEFORE downloading

I want to pull down new images from a website that is updated regularly. However, there is no API for that site, so I'm trying to fetch it by url, as the images are numbered. The way I've decided to do this is have the app query the website on first launch and loop through the URLs until I get a 404. Then I store that URL and on next launch loop through till I get another 404, etc. Now I know that is less than ideal, but I'm just building a prototype. Anyway…
Since these are images we're talking about, I can't just download them all on first launch. Waste of bandwidth, could take minutes or even hours… So I just need a way using NSURLSession or whatever to get the http status code for any given image without actually downloading it.
You can do this by getting the "HTTP Headers".
This answer will help, if you're comfortable porting Objective-C to help. I can help you with it if required.

delphi xe7 upload/download dropbox file using the rest client and show progress

using the xe7 rest client i am able to authenticate and get all kind of information like file list, account info, etc.
how can i now upload and download files with progress indication?
for uploading it will be very useful if there are some examples for small file using /files_put (max file size 150MB) and bigger one using /chunked_upload from
Dropbox API
thank you!
You should provide any code that you have problem with. Don't expect that somebody does the job for you.
To give you at least some hint:
You will send the PUT request using IdHTTP according to documentation you have already mentioned. Don't forget to add a header "Authorization" with your login information from the REST client.
IdHTTP.Put('https://api-...', FFileStream, FResponseStream);
This would block your main thread (UI) so if you want to upload/download and show progress, you have to use a separate thread - so first create a TThread, in the "Work" procedure you will run the upload/download.
Now you have to handle the progress. You can get that in the OnWork event of IdHTTP component. You will pass this status from thread to main thread. Don't forget to synchronize this call correctly - you can use IdNotify for this.
Google will help you with all these basic stuff. Then return and describe any problem.

AFNetworking upload task with POST parameters

I'm wondering how to use AFNetworking to make a POST request with a file, a few parameters and progress report of the upload.
AFURLSessionManager's uploadTaskWithRequest:fromFile:progress:completionHandler works for POST upload with progress, but I cannot figure out how to add the POST parameters.
I've also looked into AFHTTPSessionManager's POST:parameters:constructingBodyWithBlock:success:failure:, but that doesn't appear to be able to report upload progress.
How do I get the best of both worlds?
Look at using a combination of uploadTaskWithStreamedRequest:progress:completionHandler: and multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:.

webapi mvc4 fileupload with progressbar using ProgressMessageHandler Class

http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2 shows how to upload files. However I would like to have someone show me the code example where I can display the progress of the file upload using ProgressMessageHandler class. So far I was able to find examples of the class being used in WPF or console application, but I would like to use it either on the MVC controller method or the WebAPI method directly and show the upload progress to JQuery UI progress bar. Can someone post the sample code of how it can be done?
So you want to display the send progress on the client, by tracking the receive progress on the server? Keep in mind that the ProgressMessageHandler class is server-side code.
In order to do what you're proposing, every time the server receives a packet, it would need to send back to the client the details of the progress. But in order for a web browser to receive any data, it must first request it. So the browser would have to upload the file, and simultaneously be asking the server for progress updates?
I think you've got this all backwards. If you're wanting to display file upload progress in a web browser you need to look at browser technologies. Like the HTML5 upload (there's plenty of examples out there of using HTML5 to track file upload progress). Or one of the pre-HTML5 options that got a lot of mileage was Shockwave Flash plugins. GMail does, or at least did use a Shockwave Flash plugin for progress reporting on attachment uploads for example.

Upload image and text data in iphone

Hi stackoverflow friends
I want to upload text along with image to the webserver. I saw so many examples for uploading images to webserver but nobody explains how to send text from a uitextField along with image.
All of them points this link
http://iphone.zcentric.com/2008/08/29/post-a-uiimage-to-the-web/
This link gives only how to upload images only. I want to send some text values along with this. Could you please send me some example code.
Any help is Appreciable
I recommend you try ASIHTTPRequest. It allows you to easily accomplish such a task. You can create a PHP file that will receive your data via POST - ASIHTTPRequest provides some easy to use methods for this.
See here.
you can Use Evernote API for this purpose

Resources