here is my code to get the file size but I am unable to get it.:-
ImageURL is stored in realtime database
Picasso.get().load(ImageURL).placeholder(R.drawable.ic_baseline_image_200)
.into(selected_title_image)
val storageReference = FirebaseStorage.getInstance().getReferenceFromUrl(ImageURL)
ImageSize = storageReference.getBytes()
ImageSize /= 1024
Toast.makeText(baseContext, ImageSize.toString(), Toast.LENGTH_SHORT).show()
I use the reference of this question to get the size of the file using this question but I failed. I know getBytes() function will not give file size but I don't know what will give?
ImageSize is of type Long.
CodePudding user response:
Use this code. You will get the desired results.
val storageReference = FirebaseStorage.getInstance().getReferenceFromUrl(ImageURL)
storageReference.getBytes(Long.MAX_VALUE).addOnSuccessListener {it->
ImageSize = it.size.toLong()
ImageSize /= 1024
}