I am 99% sure there's an obvious answer to this, so I apologise straight up if this is a really stupid question.
I am calling the stable diffusion api (using this stability-client package).
I receive a response containing a path (as a string) to the image, it looks like this: Users/johnsmith/Documents/projects/testProject/.out/fileName.png
Now I would like to upload that image to my supabase database.
Usually when I upload a file it is via a user adding to an input type='file'
field, and it's no problem, but it seems very difficult when you only have the file path as a string.
I have tried converting the path to a blob, doing something like this:
const file = 'Users/johnsmith/Documents/projects/testProject/.out/fileName.png'
const response = await fetch(file)
const blob = await fetchFile.blob()
but this results in error TypeError: Only absolute URLs are supported
I've also tried converting the path to a file object etc. but still can't win.
Maybe one of the above methods is correct, and I'm simply doing it wrong? Or maybe an entirely different approach is required?
Would love to know if anyone has any experience uploading a file to somewhere with only the file path.