更新时间:2023-01-03 15:17:26
尝试一下:
StorageReference ref = storage.getReference();
StorageReference reference = ref.child("images.jpg");
reference.getMetadata().addOnSuccessListener(new OnSuccessListener<StorageMetadata>() {
@Override
public void onSuccess(StorageMetadata storageMetadata) {
Log.i("The size of the file is:", storageMetadata.getSizeBytes());
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
}
});
使用getSizeBytes()
,您将能够获取文件的大小.
Using getSizeBytes()
you will be able to get the size of the file.
public long getSizeBytes ():
退货 StorageReference对象的存储大小(以字节为单位)
Returns the stored Size in bytes of the StorageReference object
public StorageMetadata ():
创建一个StorageMetadata对象以保存StorageReference的元数据.
Creates a StorageMetadata object to hold metadata for a StorageReference.
有关更多信息,请检查以下内容:
For more info check this:
https://developers.google.com/android/reference/com/google/firebase/storage/StorageMetadata.html https://firebase.google.com/docs/storage/android/file-metadata