© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•5mo ago•
36 replies
skeddles

upload file to local storage bucket with service key

i cant for the life of me figure out how to upload to storage.

it works fine for authenticated users in the client.
but im trying to do it from a node.js script with the service key.

it seems to be able to download just fine, but can't upload the same file.

if (!URL || !KEY) throw new Error('Missing URL or KEY');

const supabase = createClient(URL, KEY);
const { data, error } = await supabase.storage
    .from('portfolio.quest')
    .download('index.html');
if (error) console.error('download failed, error: '+ error);
else if (!data) console.error('download failed, no data returned');
else console.log('download succeeded: '+ data);

const blob = new Blob(['poop'], { type: 'text/plain' });
const { dataUpload, errorUpload } = await supabase.storage
    .from('portfolio.quest')
    .upload('index.html', blob, {contentType: 'text/plain', upsert: true});

if (errorUpload) console.error('upload failed, error: '+ errorUpload);
else if (!dataUpload) console.error('upload failed, no data returned');
else console.log('upload succeeded: '+ dataUpload);
if (!URL || !KEY) throw new Error('Missing URL or KEY');

const supabase = createClient(URL, KEY);
const { data, error } = await supabase.storage
    .from('portfolio.quest')
    .download('index.html');
if (error) console.error('download failed, error: '+ error);
else if (!data) console.error('download failed, no data returned');
else console.log('download succeeded: '+ data);

const blob = new Blob(['poop'], { type: 'text/plain' });
const { dataUpload, errorUpload } = await supabase.storage
    .from('portfolio.quest')
    .upload('index.html', blob, {contentType: 'text/plain', upsert: true});

if (errorUpload) console.error('upload failed, error: '+ errorUpload);
else if (!dataUpload) console.error('upload failed, no data returned');
else console.log('upload succeeded: '+ dataUpload);
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Unable to upload file to a storage bucket.
SupabaseSSupabase / help-and-questions
4y ago
Upload file with french accent to bucket
SupabaseSSupabase / help-and-questions
3mo ago
Getting 400 status when trying to upload a file to storage bucket
SupabaseSSupabase / help-and-questions
4y ago
Upload file to bucket with metadata from client side
SupabaseSSupabase / help-and-questions
5mo ago