Upload to storage bucket via HTTP #5888
|
Hi community! From the documentation, I can only see guides on how to use UI, SQL, JavaScript, or Dart - not HTTP. What I am trying to achieve:
Does anyone have any thoughts? Can this even be done? Thanks in advance. |
Replies: 6 comments 5 replies
|
I found this useful for figuring out format for accessing storage from a http function in the database: |
|
Same way a download signed url, i would like to create signed upload url and allow anyone with the url to upload |
|
You can see the endpoint on the reference guide here https://supabase.com/docs/reference/storage/usage#upload-a-new-object You can also check the storage-js upload method to get inspiration: https://github.com/supabase/storage-js/blob/main/src/lib/StorageFileApi.ts#L88 |
|
I'm hitting the memory limit of Supabase function by downloading a file with axios from URL and transfer it to Supabase with the SDK. |
Had the same issue and documented my solution in an answer on StackOverflow. And I noticed that the official documentation about this aspect of the APIs is a bit incomplete, as I could not find a place where the Storage API request URI format is documented. It is a prefix of |
|
Here's a import databaseUrl from '…'
import serviceRole from '…';
export default async function uploadFile(file: File) {
const response = await fetch(`${databaseUrl}/storage/v1/object/$bucket/${file.name}`, {
method: 'POST',
headers: {
Authorization: `Bearer ${serviceRole}`,
},
body: file,
});
return await response.json();
}
if (import.meta.main) {
const file = new File(['Hello, world!'], 'hello-world.txt');
console.log(await uploadFile(file));
}You can also pass not the |
You can see the endpoint on the reference guide here https://supabase.com/docs/reference/storage/usage#upload-a-new-object
You can also check the storage-js upload method to get inspiration: https://github.com/supabase/storage-js/blob/main/src/lib/StorageFileApi.ts#L88