Retrieve public URL
Retrieve URLs for assets in public buckets
- The bucket needs to be set to public, either via updateBucket() or by going to Storage on supabase.com/dashboard, clicking the overflow menu on a bucket and choosing "Make public"
- Policy permissions required:
buckets
permissions: noneobjects
permissions: none
- Refer to the Storage guide on how access control works
Parameters
path
REQUIRED
StringThe path and name of the file to generate the public URL for. For example folder/image.png.
transform
Optional
TransformOptionsTransform the asset before serving it to the client.
width
Optional
intThe width of the image in pixels.
height
Optional
intThe height of the image in pixels.
resize
Optional
ResizeModeSpecifies how image cropping should be handled when performing image transformations. Defaults to `ResizeMode.cover`.
quality
Optional
intSet the quality of the returned image. A number from 20 to 100, with 100 being the highest quality. Defaults to 80
format
Optional
RequestImageFormatSpecify the format of the image requested. When using 'origin' we force the format to be the same as the original image. When this option is not passed in, images are optimized to modern image formats like Webp.
final String publicUrl = supabase
.storage
.from('public-bucket')
.getPublicUrl('avatar1.png');