support reuploading channel avatars

This commit is contained in:
localhost 2025-11-16 11:04:38 +01:00
parent 0340500cdd
commit c71f03dcee
1 changed files with 5 additions and 4 deletions

View File

@ -25,13 +25,14 @@ async function uploadVideo(video: string) {
}
async function uploadImage(id: string, url: string) {
const exists = await images3.fileExists(`${id}.webp`)
if (exists) return `${keys.images[0].url}${id}.webp`
const response = await fetch(url)
const buffer = Buffer.from(await response.arrayBuffer())
const bufferHash = Bun.hash(buffer).toString()
const uploaded = await images3.put(`${id}.webp`, buffer)
const exists = await images3.fileExists(`${id}-${bufferHash}.webp`)
if (exists) return `${keys.images[0].url}${id}-${bufferHash}.webp`
const uploaded = await images3.put(`${id}-${bufferHash}.webp`, buffer)
return uploaded.url.replace(keys.endpoint, 'https://s4.archive.party')
}