Skip to content

Instantly share code, notes, and snippets.

@adrianhorning08
Last active September 22, 2025 18:46
Show Gist options
  • Save adrianhorning08/585300125e6fa38f1603f16d71d6338d to your computer and use it in GitHub Desktop.
Save adrianhorning08/585300125e6fa38f1603f16d71d6338d to your computer and use it in GitHub Desktop.
Download file and upload to supabase
import fs from 'fs';
import { createClient } from '@supabase/supabase-js';
const SUPABASE_URL = process.env.SUPABASE_URL;
const SUPABASE_KEY = process.env.SUPABASE_KEY;
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
const filePath = 'video.mp4';
const bucket = 'videos'; // change to your bucket
const storagePath = `uploads/${filePath}`;
const fileBuffer = fs.readFileSync(filePath);
const { error } = await supabase.storage
.from(bucket)
.upload(storagePath, fileBuffer, {
contentType: 'video/mp4',
upsert: true
});
if (error) throw error;
fs.unlinkSync(filePath); // delete local file
console.log('Uploaded and deleted local copy.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment