This commit is contained in:
localhost 2026-01-07 20:55:23 +01:00
parent 5086d344e2
commit 7b10059b87
1 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import * as fs from 'node:fs'
const keys = JSON.parse(fs.readFileSync('s3.json', 'utf-8')) const keys = JSON.parse(fs.readFileSync('s3.json', 'utf-8'))
async function uploadVideo(video: string) { async function uploadVideo(video: string) {
const uploaded = await fetch(`${keys.endpoint}/${video.split('/')[2]}`, { const uploaded = await fetch(`${keys.endpoint}/preservetube/${video.split('/')[2]}`, {
method: 'PUT', method: 'PUT',
headers: { headers: {
'x-authtoken': keys.videos[0].secret 'x-authtoken': keys.videos[0].secret
@ -17,7 +17,7 @@ async function uploadImage(id: string, url: string) {
const arrayBuffer = await response.arrayBuffer() const arrayBuffer = await response.arrayBuffer()
const bufferHash = Bun.hash(Buffer.from(arrayBuffer)).toString() const bufferHash = Bun.hash(Buffer.from(arrayBuffer)).toString()
const exists = await fetch(`${keys.endpoint}/${id}-${bufferHash}.webp`, { const exists = await fetch(`${keys.endpoint}/preservetube-media/${id}-${bufferHash}.webp`, {
method: 'HEAD', method: 'HEAD',
headers: { headers: {
'x-authtoken': keys.videos[0].secret 'x-authtoken': keys.videos[0].secret
@ -25,7 +25,7 @@ async function uploadImage(id: string, url: string) {
}) })
if (exists.status == 200) return `${keys.images[0].url}${id}-${bufferHash}.webp` if (exists.status == 200) return `${keys.images[0].url}${id}-${bufferHash}.webp`
const uploaded = await fetch(`${keys.endpoint}/${id}-${bufferHash}.webp`, { const uploaded = await fetch(`${keys.endpoint}/preservetube-media//${id}-${bufferHash}.webp`, {
method: 'PUT', method: 'PUT',
headers: { headers: {
'x-authtoken': keys.videos[0].secret 'x-authtoken': keys.videos[0].secret