Last active
May 3, 2024 13:21
-
-
Save yudistiraashadi/e99677a7fa70657b844b880a6b0da4c0 to your computer and use it in GitHub Desktop.
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
| // 1. Pastikan local supabase sudah linked dengan supabase online | |
| // 2. `npx supabase storage ls ss:///[bucket-name]/[path-to-folder]/ --experimental` | |
| // 3. Copy semua nama file pada storage di array images_tournaments_logos atau rename sesuai keinginan | |
| import { createClient } from '@supabase/supabase-js' | |
| const supabaseOnline = createClient("[URL-SUPABASE-ONLINE]", "[SUPABASE-ONLINE-ANON-KEY]"); | |
| const supabaseSelfHost = createClient("[URL-SUPABASE-SELF-HOST]", "[SUPABASE-SELF-HOST-ANON-KEY]"); | |
| const images_tournaments_logos = [ | |
| "1.png", | |
| "1.webp", | |
| "2.jpeg", | |
| "3.jpeg", | |
| "3.png", | |
| "4.png", | |
| "4.webp", | |
| "5.webp", | |
| ] | |
| images_tournaments_logos.forEach(async (val) => { | |
| const { data, error } = await supabaseOnline.storage.from('images').getPublicUrl("tournaments/logos/" + val) | |
| if (error) { | |
| console.error({ | |
| val, | |
| error | |
| }) | |
| } else { | |
| const url = data.publicUrl; | |
| const blob = await fetch(url).then((r) => r.blob()); | |
| const { data: uploadData, error: uploadError } = await supabaseSelfHost.storage.from('images').upload(`tournaments/logos/${val}`, blob, { | |
| upsert: true, | |
| }); | |
| if (uploadError) { | |
| console.error({ | |
| val, uploadError | |
| }) | |
| } | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment