Last active
          September 22, 2025 18:46 
        
      - 
      
- 
        Save adrianhorning08/585300125e6fa38f1603f16d71d6338d to your computer and use it in GitHub Desktop. 
    Download file and upload to supabase
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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