Quickstarts
Quickstart: Storage
A bucket, an upload and a signed URL.
Storage is compatible with the Supabase Storage API and the S3 protocol.
Variables used below: $HOSTBASE_TOKEN (access token), $REF (project ref). SDKs: @hostbase/management (TypeScript) and hostbase_management (Python); full reference at /docs/api.
1. Create a bucket
Use the service_role key on the server only.
curl -X POST https://abcdefghijklmnopqrst.host.ulewicz.space/storage/v1/bucket -H "apikey: $SERVICE_KEY" -H "Authorization: Bearer $SERVICE_KEY" \
-H "Content-Type: application/json" -d '{"id":"avatars","name":"avatars","public":false}'await supabase.storage.createBucket("avatars", { public: false });supabase.storage.create_bucket("avatars", options={"public": False})2. Upload a file
curl -X POST https://abcdefghijklmnopqrst.host.ulewicz.space/storage/v1/object/avatars/me.png -H "apikey: $ANON_KEY" -H "Authorization: Bearer $USER_JWT" \
-H "Content-Type: image/png" --data-binary @me.pngawait supabase.storage.from("avatars").upload("me.png", file, { contentType: "image/png" });supabase.storage.from_("avatars").upload("me.png", open("me.png", "rb").read(), {"content-type": "image/png"})3. Signed URL
A link valid for one hour.
curl -X POST https://abcdefghijklmnopqrst.host.ulewicz.space/storage/v1/object/sign/avatars/me.png -H "Authorization: Bearer $USER_JWT" -H "apikey: $ANON_KEY" \
-H "Content-Type: application/json" -d '{"expiresIn":3600}'const { data } = await supabase.storage.from("avatars").createSignedUrl("me.png", 3600);supabase.storage.from_("avatars").create_signed_url("me.png", 3600)