title: upload image files from IOS to web server
body: <p>What is the best way to upload image files to web server in java considering IOS9 and swift 2.</p>
  
  <p>Upon searching, I realised that similar question was asked and many different methods are available online to upload images. However I am not sure on what is the best method to follow.</p>
  
  <p>I tried the following approaches and noticed that it takes about a minute to upload an image.</p>
  
  <p>****Approach 1:****</p>
  
  <p>Using NSURLSession and invoking “POST” method of the java servlet
  Send as JSON as stated in this <a href="http://paoloibarra.com/2014/10/11/Image-Upload-To-RESTful-API-Swift/" rel="nofollow noreferrer">example</a></p>
  
  <p>Append image to httpbody itself as stated in this <a href="http://swiftdeveloperblog.com/image-upload-example/" rel="nofollow noreferrer">example</a></p>
  
  <p>****Approach 2:****</p>
  
  <p>Using NSURL and invoking a javascript method as in this <a href="http://www.kinderas.com/technology/2014/6/15/wkwebview-and-javascript-in-ios-8-using-swift" rel="nofollow noreferrer">example</a></p>
  
  <p>I also read about AFNetworking 2.0 (<a href="https://stackoverflow.com/questions/19836432/uploading-image-with-afnetworking-2-0">ex</a>) and I am not sure if it can bring any performance increase to the uploading process.</p>
  
  <p>Our users might take around 100 of pictures everyday and the images needs to be uploaded to web server for further processing. </p>
  
  <p>Please review and suggest your views. Many thanks.</p>