Download a file
Downloads a file from a private bucket. For public buckets, make a request to the URL returned from getPublicUrl
instead.
- RLS policy permissions required:
buckets
table permissions: noneobjects
table permissions:select
- Refer to the Storage guide on how access control works
Parameters
The full path and file name of the file to be downloaded. For example folder/image.png
.
Transform the asset before serving it to the client.
Specify 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.
The height of the image in pixels.
Set the quality of the returned image. A number from 20 to 100, with 100 being the highest quality. Defaults to 80
The resize mode can be cover, contain or fill. Defaults to cover. Cover resizes the image to maintain it's aspect ratio while filling the entire width and height. Contain resizes the image to maintain it's aspect ratio while fitting the entire image within the width and height. Fill resizes the image to fill the entire width and height. If the object's aspect ratio does not match the width and height, the image will be stretched to fit.
The width of the image in pixels.
const { data, error } = await supabase
.storage
.from('avatars')
.download('folder/avatar1.png')