Yes it is possible! Instead of some creepy complex lines of code here is my shortcut to get this downloadurl from the Firebase repository in kotlin
Note : based on the latest version of Firebase, there is no getdownloadurl () or getresult () method ( this time they are obsolete)
So, the trick I used here is that by calling UploadSessionUri from the taskSnapshot object, which in turn returns the downloadurl along with the type of download, tokenid (one that is only available for a shorter amount of time) and with some other things.
Since we only need to download the URL, we can use the substring to get the downloadurl and combine it with alt = media to view the image.
var du:String?=null var du1:String?=null var du3:String="&alt=media" val storage= FirebaseStorage.getInstance() var storagRef=storage.getReferenceFromUrl("gs://hola.appspot.com/") val df= SimpleDateFormat("ddMMyyHHmmss") val dataobj= Date() val imagepath=SplitString(myemail!!)+"_"+df.format(dataobj)+".jpg" val imageRef=storagRef.child("imagesPost/"+imagepath) val baos= ByteArrayOutputStream() bitmap.compress(Bitmap.CompressFormat.JPEG,100,baos) val data=baos.toByteArray() val uploadTask=imageRef.putBytes(data) uploadTask.addOnFailureListener{ Toast.makeText(applicationContext,"Failed To Upload", Toast.LENGTH_LONG).show() }.addOnSuccessListener { taskSnapshot -> imageRef.downloadUrl.addOnCompleteListener (){ du=taskSnapshot.uploadSessionUri.toString() du1=du!!.substring(0,du!!.indexOf("&uploadType")) downloadurl=du1+du3 Toast.makeText(applicationContext,"url"+downloadurl, Toast.LENGTH_LONG).show() } }
Hope this helps!
source share