From 65017a44ee2d15cfd3fe56b43e57bdaa63cde338 Mon Sep 17 00:00:00 2001 From: topjohncian <45138629+topjohncian@users.noreply.github.com> Date: Sun, 29 May 2022 12:15:54 +0000 Subject: [PATCH] Fix: preview api returns raw name --- service/explorer/file.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/service/explorer/file.go b/service/explorer/file.go index 15c88b2e..28bcb78c 100644 --- a/service/explorer/file.go +++ b/service/explorer/file.go @@ -354,6 +354,9 @@ func (service *FileIDService) PreviewContent(ctx context.Context, c *gin.Context c.Header("Cache-Control", "no-cache") } + // 设置文件名 + c.Header("Content-Disposition", "attachment; filename=\""+url.PathEscape(fs.FileTarget[0].Name)+"\"") + http.ServeContent(c.Writer, c.Request, fs.FileTarget[0].Name, fs.FileTarget[0].UpdatedAt, resp.Content) return serializer.Response{