elenche
elenche

Reputation: 181

Download most recent file from Firebase Storage

I want to know if there is a way to download the most recent file from Firebase Storage (to my Android app)? There is a way to download the file if you know the name:

storageRef.child("users/me/profile.png").getBytes(Long.MAX_VALUE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
    @Override
    public void onSuccess(byte[] bytes) {
        // Use the bytes to display the image
    }
}).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception exception) {
        // Handle any errors
    }
});

The idea is to upload a local image using a python script, issue a push notification through Firebase Notifications (already done), and download the newest image after receiving the notification.

Upvotes: 0

Views: 1626

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

Cloud Storage for Firebase does not have a concept of "most recently uploaded file". You will need some other source of metadata that records and describes what you're trying to do. For Firebase apps, this would typically be some data in Firebase Realtime Database that you can query. The client that uploads the file needs to also update the database to indicate what it has done.

Upvotes: 1

Related Questions