File Upload
For file upload, we used the Firebase Client together with Firebase Storage for our storage needs. We store the users profile image in a subfolder named /users.

Image resize extension

We use Resize Image extension for resizing every image uploaded to the storage. Every image uploaded to the storage is resized to our size preference (200px x 200px).

Setting your image resize

If you want to install it from the cmd, you can execute:
firebase ext:install storage-resize-images --project=projectId
With your own projectId
Installing the extesion via de Firebase dashboard:
  1. 1.
    Go to your Firebase Proyect on Firebase Console
  2. 2.
    Select extensions from the sidebar
  3. 3.
    Search for Resize Images extension
  4. 4.
    Click install on the extension
  5. 5.
    On extension configuration set sizes of resized images to 200x200 and the deletion of original file to true
  6. 6.
    Click on install extension
In case you do not want to upload a resized version and upload the original file, you should avoid step 5.

Storage Rules

To make images reachable, we needed to set our storage rules to allow users to write on the storage made for the user logo, only if they are authenticated, but they can always read, this was set for saving the user´s logo path on the database.

Should look like this

service {
match /b/{bucket}/o {
match /users/{imageId} {
allow write: if request.auth!=null;
allow read: if true;
Last modified 1yr ago