Код: Выделить всё
import fs from 'fs'
import { createClient } from '@supabase/supabase-js'
import 'dotenv/config'
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY)
const fileBuffer = fs.readFileSync("./image.png")
async function uploadFile(buffer) {
const { data, error } = await supabase.storage
.from('Memes')
.upload('public/hehe.png', buffer, {
contentType: 'image/png',
upsert: true
})
if (error) {
console.log("Error Details:", error)
} else {
console.log("Success! File uploaded to:", data.path)
}
}
uploadFile(fileBuffer)
Код: Выделить всё
Error Details: StorageUnknownError: Unexpected end of JSON input
at file:///C:/Users/Tejas/OneDrive/Desktop/Programs/WebDev/Supabase%20Test/node_modules/@supabase/storage-js/dist/index.mjs:168:10
at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {
__isStorageError: true,
originalError: SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at parseJSONFromBytes (node:internal/deps/undici/undici:6433:19)
at successSteps (node:internal/deps/undici/undici:6414:27)
at readAllBytes (node:internal/deps/undici/undici:5380:13)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
}
- Сегмент открыт
- Ключ API/URL правильный
- Политики разрешают вставку
Подробнее здесь: https://stackoverflow.com/questions/798 ... to-storage
Мобильная версия