Last active
September 22, 2025 18:46
-
-
Save adrianhorning08/585300125e6fa38f1603f16d71d6338d to your computer and use it in GitHub Desktop.
Revisions
-
adrianhorning08 revised this gist
Sep 22, 2025 . 1 changed file with 18 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,25 @@ 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.'); -
adrianhorning08 created this gist
Sep 22, 2025 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ import axios from "axios"; import { createClient } from "@supabase/supabase-js"; const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY); const url = "https://example.com/image.jpg"; // change this const bucket = "images"; // your bucket name const path = `uploads/${Date.now()}.jpg`; // path in bucket // download as buffer const response = await axios.get(url, { responseType: "arraybuffer" }); const buffer = Buffer.from(response.data); // upload to supabase const { data, error } = await supabase.storage .from(bucket) .upload(path, buffer, { contentType: response.headers["content-type"], }); if (error) { console.error(error); } else { console.log("Uploaded:", data); }