-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exists
method to storage
#266
Comments
exists
method to storage
There is currently no api enpoint for this. See the documentation. For the time being, you can create your own postgres function, which queries the |
@caseycrogers As @Vinzent03 has said, there is currently no APIs for that, so I would recommend creating an issue on the Storage API repo. |
Come to think about it, what is the use case for this method? In what scenario would you not know if a file exists or not? The way use storage is that after I upload a file, I either save the public URL or the path to the file in a database, and when I need to access the file, I would just access it via the saved URL or generate a URL from the saved path. |
You may have paths, where you don't have to save the path, because it's not random, but constructed from other parameter. For example, you may have a directory with profile images, where the file name is the uid of the user. You don't have to specifically save the filename, because you already know the uid. |
@Vinzent03 I fear that adding a |
@dshukertjr I'm not sure if you fully understood my use case. Let's say profile images are stored in a predefined directory with the user's uid as the file's name. How do you know on the client whether you already uploaded an image or not? I think the only ways are providing an extra method in the client library, or the user uses a |
@Vinzent03 At least for now, there are some workarounds like doing a head request or to use a Let's keep this issue open to see if more users demand this feature! |
Ran into this same exact use case today, so just want to give my +1 to this feature getting implemented. While I do have a fallback image, I'd rather not show the request error in the console if it could be avoided. EDIT: Just wanted to include the database postgres function call I created for those stuck on this:
And the call to it:
|
Transferring this issue to the storage-api repo to discuss its implementation on the backend. |
We already have a backend method to check the existence of an object, simply using a HEAD request instead of a GET on a specific object will return empty content if the item exists else 404 We should probably update the client SDK to implement this method |
Running into this issue. User Avatars. I want to check if the folder exists before i create the img source url like above. |
And why is this yet not available? |
Authed HEAD request for reference
|
This will be a useful method. It looks like Google Cloud Storage (and by extension, Firebase Storage?) has a similar method. |
I would like to be able to check if a file exists in Supabase storage without having to download it:
final bool fileExists = await supabase.storage.from('some-bucket-id').exists('/some/path');
The text was updated successfully, but these errors were encountered: