Got a quick question about Storage-kt when it come...
# supabase-kt
b
Got a quick question about Storage-kt when it comes to adding/deleting and paths. Given an object
image_A.png
, a "folder"
images
and a bucket
artists
, when adding using the following code:
Copy code
val storagePath = supabaseClient.storage.from("artists").upload(path = "images/image_A.png", data = file.readBytes())
the following path is returned
artists/images/image_A.png
. However, when attempting to delete using the returned string, using the following code:
Copy code
supabaseClient.storage.from("artists").delete(path = storagePath)
the deletion is unsuccessful because the delete function will now be looking for
artists/artists/images/image_A.png
. My question is whether there is an easy way around this issue without having to do any string manipulation to the String returned by the add storage function?
Would there be any reason to just use the path provided to the upload method? ("images/image_A.png" instead of using the returned path.)
j
Would there be any reason to just use the path provided to the upload method? ("images/image_A.png" instead of using the returned path.)
The current return value is just what Supabase provides in their response. I'm not sure why you would use that in the scope of a client library (you could use that value 1:1 in a request:

https://id.supabase.co/storage/v1/bucket/folder/file.png

)
My question is whether there is an easy way around this issue without having to do any string manipulation to the String returned by the add storage function?
Well, you can just use the parameter you put in the upload method, but we could change the return value to provide both.
b
The reason I was wanting to make sure was because it could be possible that Supabase does something with the upload, resulting in a slightly different final path than what was inputted for the upload. If there is no chance of that ever happening, I can certainly use the inputted path. 🙏🏼
j
If there is no chance of that ever happening, I can certainly use the inputted path
Yes, you can safely use that. There will still probably be some changes to the return value to match the other client libs, but that doesn't matter for the actual file upload.
b
Perfect. Thanks for the quick reply. 👍🏼