0

What I want to do is to check the md5Hash of a file metadata stored in my firebase Storage, I have done it and its working like this

   refToFile.getMetadata().addOnSuccessListener(new OnSuccessListener<StorageMetadata>() {
            @Override
            public void onSuccess(StorageMetadata storageMetadata) {

               String hash =  storageMetadata.getMd5Hash();
                Log.e("md5hash", "onSuccess: "+hash );
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception exception) {
                // Uh-oh, an error occurred!
            }
        });

Now, I want to check if that hash is the same as one file I have in my externalStorage (file inside my phone)

What Im trying to do is this

1 .- Download that file from Storage

2 .- Check if that md5Hash has not changed (so I know that the file is not new)

3 .- If I upload the same file and replace it, I will check the file md5Hash from firebase and compare to the md5Hash of the file I stored in my phone, so I know that the file in the Storage is new and I can prompt the user to download that new file

Question

Is there any method to get the md5Hash from a file inside my phone ?

For example

File file = new File();
file.getMd5Hash...

I suppose that the md5Hash of a file downloaded with firebase is the same as the firebase file metadata stored in my phone (because is the same file).

Todd
  • 179
  • 15
  • is that md5Hash the same as the file downloaded doug ? I mean, I download a file from firebase, its hash is this one lets say KjshgmwO20== , if I store that file into my phone , then if I request that md5 again it should be the same, Im right ? – Todd Oct 04 '18 at 15:21
  • I dont want to generate a hashmd5 key , I want to get it from the file – Todd Oct 04 '18 at 16:25

0 Answers0