store profile avatars in R2
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-07-08 11:40:50 +09:00
parent 0112956835
commit 19b8e40b72
7 changed files with 171 additions and 7 deletions
+6 -3
View File
@@ -653,12 +653,13 @@ authRoutes.get('/me', authRequired, (c) => {
authRoutes.get('/profile/avatar', authRequired, async (c) => {
const image = await findUserProfileImage(c.get('user').id)
if (!image) return c.body(null, 404)
if (image.url) return c.redirect(image.url, 302)
c.header('content-type', image.mimeType)
c.header('cache-control', 'no-store')
if (image.updatedAt) c.header('last-modified', image.updatedAt.toUTCString())
return c.body(new Uint8Array(image.data))
return c.body(new Uint8Array(image.data!))
})
authRoutes.get('/users/:userId/avatar', authRequired, async (c) => {
@@ -667,12 +668,13 @@ authRoutes.get('/users/:userId/avatar', authRequired, async (c) => {
const userId = c.req.param('userId')
const image = await findUserProfileImage(userId)
if (!image) return c.body(null, 404)
if (image.url) return c.redirect(image.url, 302)
c.header('content-type', image.mimeType)
c.header('cache-control', 'no-store')
if (image.updatedAt) c.header('last-modified', image.updatedAt.toUTCString())
return c.body(new Uint8Array(image.data))
return c.body(new Uint8Array(image.data!))
})
authRoutes.get('/users/avatar', authRequired, async (c) => {
@@ -686,12 +688,13 @@ authRoutes.get('/users/avatar', authRequired, async (c) => {
const image = await findUserProfileImage(user.id)
if (!image) return c.body(null, 404)
if (image.url) return c.redirect(image.url, 302)
c.header('content-type', image.mimeType)
c.header('cache-control', 'no-store')
if (image.updatedAt) c.header('last-modified', image.updatedAt.toUTCString())
return c.body(new Uint8Array(image.data))
return c.body(new Uint8Array(image.data!))
})
authRoutes.put('/profile/avatar', authRequired, async (c) => {