putBytes() vs putFile() for uploading images - android

I want to upload images from app to firebase storage and there is fragment in app where I want to
show images on server in recycler view. Should I use putBytes() or putFile()? such that when I display images using recylerview in OnBind() function images load faster.

putFile() is just a convenience method for automatically reading the file and using putBytes() to upload it. Either way, the speed of the upload is limited by the speed of the device's connection to Cloud Storage.

Related

How to download only the latest images from Firebase Storage?

I have the following problem and do not quite know how to solve it:
I am loading pictures from one device to Firebase Storage Cloud. With another device, I want to download them from Firebase Storage.
So far my implementation looks like this. Every time I open the app it re-downloads and displays all the images. I can't effectively get it to save the images in the app (NOT GALLERY) and just check if there is a new image that hasn't been downloaded yet.
What you're looking for, is to cache images on an Android device. This means that once you download it, you will not need to download it again, it will always be read from the cache.
For Android, there are a few libraries that do that. One would be Glide, and another one would be Picasso. If you're using however Kotlin and Jetpack Compose, then you can use Coil.

Android - Storing and loading a folder of images stored on the web

I have a folder on my computer with many images. I want to have my app be able to load all of these images into a View. I have no problem loading one image from its url (using Picasso) but I want to know how to load a folder of them (i.e the amount of images may change).
I was thinking that I could use a Google Drive public folder to store the images, but how could I get the images from within the folder (i.e if I had the folder's URL could I use Java to "open and look inside" it)? Is there a better (and free) way than Google Drive to store the images? Maybe an imgur album or some kind of free server hosting service?
You can use Firebase or Alternative use is Imgur . You store images there and the links of images tou can store in a db (sql Lite) and just add connection of db in main.activity Here you can learn how
You should consider using Firebase for this. Upload your Images in the Firebase Storage and store the link in the database. Once done, you can show all the Images in your app and also dynamically add the images.

How to download thumbnails of images stored in firebase using glide

I want to download the images thumbnail not the entire image from my firebase storage. I am using glide to load the images but i am not getting how can i load image thumbnails as it will be quicker and memory efficient.
You first need to create thumbnails for the images, likely using something like Google Cloud Functions or Google App Engine. You can write a function that takes the original image, and runs it through ImageMagick, then saves it back to Firebase Storage at a known location, say images/myImage_resized_<height>_<width>.png, which your client can then fetch.
Alternatively, you can use Imgix or Cloudinary to serve smaller images stored in Firebase Storage by providing our Download URLs to those services and fetching the images from there. If you're willing to do some more work, Google App Engine offers the App Engine Images API for free, which does many of the same things.

How to store images in android other than sdcard and database

I am working on one android application,in that I have to download images from web and I am showing in listview using imageloader.Next time if I am not connected to internet I have to show saved images.So that If I want to save downloaded images where I have to store.I have two ways one way I have to store in sdcard and another one is in database.Is there any alternative way to store images.Image sizes are very small
Try it with Cache? Best way to do this:
http://www.androidhive.info/2014/05/android-working-with-volley-library-1/
Volley gives you a NetworkImageView, this is a "normal" ImageView, but you can give it a URL and volley will do all the rest for you (download, or load from cache, if already loaded).

How to avoid to download the video or image from server once we have seen(Like it should store in cache memory)?

I have problem with my app, it's very slow because of using Video and images. When I play video or show images it takes time to download, the app would close during this time or it will take for ever. How can I avoid this problem? Once we have seen the image or video it should not download from server again, please give me the solution for this(Like Facebook).
First you should download the video or image in an asynctask inner class, this is why the app freezes while downloading.
You are downloading on the UI thread and this freezes your app, AsyncTask is the way to go.
Second when download is complete you could save the video, image to sdcard so you won't have to download them again next time. When you want to view the video the second time you will only have to know the file name so you could grab it from sd card. You could make a method that determines if a video on sd card is considered outdated and delete that file if true.
Also as other comments say, AQuery ( Android Query) is a library (facilitates chaining like jQuery does for javascript) that offers a lot of convenience methods for file downloading and other cool stuff. A short Google query for AQuery term should reveal tutorials and download sources.
You can use AndroidVideoCache for caching video while streaming. It allow to use cached video after single viewing.

Categories

Resources