Android : How to get large data above 20mb from server to android - android

In my android application when a user login from a new device i want to download all his data from the server database that may be more than 20mb in size.This data include bitmap images that are converted to string.When a user uploads a image what i done so far is i just convert this image to bitmap and then convert it to string and then save this to database,after that this data will save to server database by syncing.If the same user login from a new device i need to take all those data from server with a webservice.Right now i am using resttemplate to load this data, but the problem is when there is more than 20mb of data that mainly contains some image data the webservice may take more time based on the image size.Is there any better way to deal with images??

You can use aws s3. The images can be saved in the s3 buckets, which provides us with the URL. While loading all the details in the app instead of loading the whole image, only the s3 URLs needed to be send. The images can be downloaded later while loading them into the imageviews using libraries like Picasso or glide.

Do not use bitmap images (what ever you mean by it) but jpg's. Dont convert them to base64 as the amount of data will increase by 30%. Dont save them in a database on your server but on the server file system as normal files.
Then just give twenly urls for twenty files to the Android client and let the Android client decide when and how to download the images from url.
Alternatively you can let your base64 encoded images in the database. Just send twenty ids or file names (for twenty files) to the Android client. Then let the Android client decide when it wants to download an image using an url with parameter id.

Related

retrieve images from firebase storage to recyclerview without database

Hi guys I am making a wallpaper android app.I have stored all my images in firebase storage. Now I have a recyclerview and want to retrieve each of the images into that recyclerView by getting list url of the folders.Is there any way to do that without using the database.I have pasted the json file into my app.
In order to download a image/images from Firebase Storage, you first need to have the corresponding url/urls. To download an image, it requires four steps:
Upload the image to Firebase Storage.
Save the corresponding URL to Cloud Firestore/Firebase Database database while uploading.
Attach a listener on the folder you have saved the image.
Display the image.
So there is no way in which you can download an image without knowing the URL. You cannot get the image list URL directly from Firebase Storage.
First at all you need to have corresponding URLs of your image data stored in Firebase, as mention Alex Mamo. You can build list of this urls during upload or copy them from Firebase Console. Storage API doesn't provide any way how to retreive list of stored files.
Also, you can find Download URL in Image detail/properties. Then you can insert urls into JSON file (or another file, service, firebase storage, whatever) and load them in app.
But be careful, this is not a good idea because Firebase Storage (especially spark plan has limits) allow you download 1GB/day and only 50k/day (download/upload) operations. That will be wasted pretty soon if you don't optimise your data and number of reading operations.
Tip: When you select pay as you go most expensive is GB Downloaded, so you absolutely should store at least 1 thumbnail which will be shown in your recycler view.

Low resolution Thumbnails management in Chat Applications

I am dubious about the approach usually followed by popular Chat applications like Whatsapp, Wechat etc. It is seen that these apps share a low -resolution blurred out image of the actual image/video file. How is this managed?
My concern is the space management at the server end. Does the client process the original image and create a low-res version and sends 2 requests (Original+blurred file) to the server? Following which, the blurred image being lower in size is shared with others who trigger a GET request for the original image/video file.
Or does the server itself does some processing one the Original file received and make a low-res version out of it. And proceeds as above.
In both cases i could think of, space is being eaten up at the server end with 2 instances of each image/video being shared.
Kindly let me know how this is genrally carried out.
Would be grateful!
you need to upload your original files on your server(web server) and using web server you can send thumbnail of file base64 to ejabberd server. create blurred image from client side not server side(less work load on server if you do it client side).In this case you need to create custom ejabberd module via this custom module http server communicate from ejabberd server.

Download the image by url , or convert it with base64

My app receive a jsonArray that contain names of categories and their images urls. which is the best to do:
send the url of the images and after that download them.
or instead of sending the url I will send the images converted with base64.
actually I know that base64 is more larger, but I just want to do a trade off between the size and the number of the requests, I mean which is better: to get one large request, or get a lot of small request ?
I have about 20 categories and the image is just 20-30 Kb.
1: Send the image urls and download and heavily cache device side, this tends to 'Always' be the best way.
The JSON response should have an array of your objects each with a name and a URL, simply get the JSON response in your app and parse out the relevant URLS and names, downloading each using Picasso (As discussed in earlier question) as you go, it will cache them for faster access in future also.

How to send image from one device to another in background on Android?

I need a workaround for the following task:
I have a JPG (of whatever) picture on my sd card, and I need to send it to another device in the background. How should I do that?
Best way (in theory) would be via MMS, but after a lof of searching, I can say that there is no official and trustful (and working) way to do that in the background.
Any ideas, samples, even proofs that it can be done are welcomed! All that matters is that a remote device must have access to that image.
if you want the sending to happen in background you could use android beam, but you would have to get both devices cloth together.
And as i am not sure about what u mean by background i can't be sure that thats what you want. :)
First of all you need to create a "Service" in App which will run in background and do all tasks given below. A central PHP Server required for this task. Other device can download that file by the same HTTP request method.
Convert image to base64 string--
How to convert a image into Base64 string?
you can convert byte array to suitable types- string or delimiter(, or .) separated string
Then create a HTTP request--
Make an HTTP request with android
for HTTP request create a url like this - https://www.yoursite.com/post/?code="base64 string goes here"
-Receive data in php file on your server by $_GET global array
$code = $_GET['code']
In php file convert base64 code to original image.
How to decode a base64 string (gif) into image in PHP / HTML
get image from base64 string
Maybe I explained badly my needs. An important thing I missed is that the same person has access to both device. I solved it by uploading the image to google drive.

Download and save static images in phone

In my application when i query a http URL i get list of object, some times these object needs to be rendered on listview and sometimes in my custom view.
Each of the object which i receive from server has image tag, most of the time images are always constant i.e same image URL only.
I just want to download the images once, & also my app should have to download once in a while when the images got changed in server. What is the best way?
I know like, we need to perform operation in thread, but not getting the exact idea of how to do?. how to check for change of image & efficient way of storing them. Any hint
For storage, I recommend Internal Storage
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
And for downloading
http://developer.android.com/reference/android/os/AsyncTask.html
You can create a AsyncTask where you pass a ImageView, where you want to show the img, with the url as a tag. And check in the internal storage if you have that img already saved if not just download it.

Categories

Resources