from.getPublicUrl()

Retrieves the URL for an asset in a public bucket. This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.

1const { data } = supabase
2  .storage
3  .from('public-bucket')
4  .getPublicUrl('folder/avatar1.png')

Parameters#

  • pathrequired
    string

    The path and name of the file to generate the public URL for. For example folder/image.png.

  • optionsoptional
    object

    No description provided.

      Properties
    • downloadrequired
      string
      |
      boolean

      triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.

        Properties
      • stringrequired
        object

        No description provided.

      • booleanrequired
        object

        No description provided.

Notes#

  • The bucket needs to be set to public, either via updateBucket() or by going to Storage on app.supabase.com, clicking the overflow menu on a bucket and choosing "Make public"
  • RLS policy permissions required:
    • buckets table permissions: none
    • objects table permissions: none
  • Refer to the Storage guide on how access control works

Examples#

Returns the URL for an asset in a public bucket#

1const { data } = supabase
2  .storage
3  .from('public-bucket')
4  .getPublicUrl('folder/avatar1.png')