How to Upload Image to Firebase Cloud Storage in Android Studio using Java

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys in this video you will learn how to upload image to Firebase cloud storage in Android Studio let's start by adding Glide dependency [Music] [Music] then let's connect our project to Firebase [Music] thank you [Music] after connecting let's open Firebase and configure cloud storage foreign [Music] in order to be able to upload image from our Android app we should modify the rules of the cloud storage for now I'm setting both read and write rules as true you can configure it as however you wish thank you [Music] now let's go to Android studio and add Firebase Cloud dependency in our project [Music] now with this let's build the UI of the app [Music] inactivitymaine.xml let's add a toolbar followed by a progress indicator below it and then followed by an image View and a button to select image from device and another button to upload image to Firebase foreign [Music] [Music] this progress indicator will display the progress of the image while uploading [Music] [Music] we will be using this image view to display the selected image [Music] [Applause] thank you [Music] [Music] foreign [Music] [Music] [Music] [Music] activity.java file let's start by declaring the variables here the storage reference is like a pointer to a path in the cloud in order to upload or download files we must create a storage reference [Music] URI is where we will assign the selected image [Music] this activity result launcher is where we will handle the selected image [Music] [Music] if the selected image result is ok then we will enable the upload button store the image path and the variable image and display the selected image using Glide thank you [Music] foreign [Music] [Music] if the result code is not okay then we will display this toast message [Music] please now let's write some code in the oncreate function first let's initialize Firebase in our app using the following code then let's assign all the declared variables [Music] [Music] foreign [Music] now let's set on click listener to select image button when this button is clicked we'll launch an intent to select image using activity result launcher that we previously declared [Music] you can also select and upload other type of files by specifying the file type here [Music] then let's set on click listener to upload image button when this button is clicked we'll call upload image function by parsing image URI finally let's create upload image function [Music] to upload a file first we should create a reference to the path where we need the file to be in the cloud storage the path can be set using the function child with the path or folder name within it the last string inside parsed here will become the name of the file in the cloud storage in this case images is a folder and I've set the file name as a random uuid string but you can even set it as the original file name or some other name you want then to upload the file let's call the function put file using the reference and add some listeners to the process if the upload is successful then we will show this toast message [Music] if the upload failed then we will display this error toast message [Music] finally using this listener we shall display the progress of the upload in the progress indicator [Music] now let's run this code you can use this link to share the files thank you so much for watching make sure to like share and comment this video and don't forget to subscribe the channel happy coding
Info
Channel: Everyday Programmer
Views: 4,545
Rating: undefined out of 5
Keywords: programmer, apps, apks, development, apple, developer, client, android, new, hero, knowledge, programming, for, beginners, language, training, setup, laptop, every, one, using c, with c, line, studio, 2023, firebase, cloud, storage, tutorial, example, implementation, how, to, with, java, app, application, everyday, references, path, progress, upload, save, google, initialize, instance, math, task, child, snapshot, ref, string, uri, file, console, proof, college, project, add, send, success, put, coding, without, bugs, working, github, source, code, link
Id: _mo0vPfOaAQ
Channel Id: undefined
Length: 11min 50sec (710 seconds)
Published: Tue Jul 11 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.