JavaScript: exists

Checks the existence of a file.

This reads the object's metadata, so the result is false only when Storage reports that the key does not exist: an error with code NoSuchKey, or an HTTP 404 with no error code. In that case data is false and error holds the original error.

Every other failure throws instead of returning false, including an invalid or expired JWT (InvalidJWT), a missing bucket (NoSuchBucket) and network errors. With throwOnError(), a missing key throws as well.

Parameters

Examples

Check file existence

const { data, error } = await supabase
  .storage
  .from('avatars')
  .exists('folder/avatar1.png')