From 4d2b65e34c6d01800273009d60756205c08cb0c3 Mon Sep 17 00:00:00 2001 From: link Date: Thu, 11 Jan 2024 09:21:47 +0000 Subject: [PATCH] add user avatar --- route/v1/user.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/route/v1/user.go b/route/v1/user.go index 5cd974d..bdc352e 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -228,6 +228,13 @@ func GetUserAvatar(c *gin.Context) { return } user.Avatar = "/usr/share/casaos/www/avatar.svg" + if file.Exists(user.Avatar) { + c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) + c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, value") + c.File(user.Avatar) + return + } + user.Avatar = "/var/lib/casaos/www/avatar.svg" c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, value") c.File(user.Avatar)