I'm facing the following issue:

  1. I upload an Image to Firebase Storage
//Start the upload
await StorageHandler.instance.uploadTask(mediaIDPath, largeFile);
  1. Once the upload is completed, the Firebase Extension "Resize Image" will be triggered. The Resized Imaged will be stored separately in another path in my FirebaseStorage

  2. In order to make sure that the image is resized I'm waiting 4 seconds in my code (which is not the right way how to solve this problem)

//Start the upload
await StorageHandler.instance.uploadTask(mediaIDPath, largeFile);

//After the upload is completed, wait 4 seconds until the image is resized
await Future.delayed(Duration(seconds: 4));
  1. Then I'm fetching the URL of the resized Image. I need the download URL immediately in order to display image in a GridView as soon as the image is resized and added to the other path which I've mentioned in point 2.
//Start the upload
await StorageHandler.instance.uploadTask(mediaIDPath, largeFile);

//After the upload is completed, wait 4 seconds until the image is resized
await Future.delayed(Duration(seconds: 4));

//fetch the imageURL of the resized Image
gridURL = await StorageHandler.instance.getImageURLFromStorage(mediaIDPathResizedFile);

To wait 4 seconds is not the right way. Therefore I'm seeking for a possibility to get a feedback from the Storage that the Resize is completed that I can fetch the download URL afterwards. I couldn't find any method in Firebase which provides this functionality.

Important note: I don't want to resize the image on client side to avoid more upload operations and keep the firebase costs at the minimum!

Does anyone have an idea for a workaround to avoid waiting 4 seconds in my case?

I hope I explained my problem clear enough and looking forward for helpful suggestions.

1

There are 1 best solutions below

3
On

There is nothing built into the resize images extension to signal completion to the calling client.

The typical way to implement this yourself would be to create a Cloud Function that triggers when a file being written to Cloud Storage, and if the file is a thumbnail to implement the send a signal to the calling client (for example, by storing information in the metadata of the file on how to reach the client) through something like FCM, or one of Firebase's databases (Realtime Database, or Cloud Firestore).