Recent Posts

Site Creator

By

By

By

Sharing / uploading image to server

Posted on

Dear Reader

Few days back me and my students were working on an application in which we had a requirement to share an image to a Server.

Since this was a sort of Chat Application so it was quintessential functionality some how recipient gets notified of shared image  whenever image is shared with recipient. So recipient can fetch the image from Server,  on getting a notification.

 

So Let use the famous conceptual way Divide and Rule / Conquer method. Lets divide our big problem into two or more sub problems.

We can divide the problem as

  1. Sharing / uploading image to server
  2. Getting FCM notification from Server
  3. When notification arrives at Client end , Fetch image from Server.

 

Further In this post we gonna see how to upload image to server

 

 

Below lines are important

 

 

There was a bug in Base64 encoding due to which uploaded image on server was corrupted. So options Base64.NO_WRAP | Base64.URL_SAFE are used.

 

Rest other things like uploading image via HTTPURLConnection and posting data to server is trivial code.

 

Happy Coding !

 

 

 

 

 

 

 

 







Disclaimer: The aforesaid writeup by Relsell Global writer is for the general understanding of the readers. It does not render any professional advice or opinion.

SHARE THIS PAGE!