Search code examples
supabaseflutterflow

Loading a private image from Supabase in Flutterflow


Flutterflow has a handy native feature for uploading images to Supabase storage, but it's not clear how the uploaded image can then be accessed if, as in my case, Supabase has a security policy on the bucket.

The policy is by design - I only want user-uploaded images to be available to the user that uploaded them, but I can't see an obvious way to make authenticated requests to Supabase to get the image, i.e. the GET needs the bearer token. Any clues?


Solution

  • If you have a private bucket and want to retrieve images from the bucket as a signed in user, you have to first create a signed URL and then load the image using the generated signed URL.

    final String signedUrl = await supabase
      .storage
      .from('avatars')
      .createSignedUrl('avatar1.png', 60);