mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-08 17:08:04 +02:00
feat: add MIME type support for raw file serving (#417)
This commit is contained in:
@ -3,9 +3,11 @@ package gist
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"strconv"
|
||||
|
||||
"github.com/thomiceli/opengist/internal/db"
|
||||
"github.com/thomiceli/opengist/internal/web/context"
|
||||
"strconv"
|
||||
"github.com/thomiceli/opengist/internal/web/handlers"
|
||||
)
|
||||
|
||||
func RawFile(ctx *context.Context) error {
|
||||
@ -18,7 +20,8 @@ func RawFile(ctx *context.Context) error {
|
||||
if file == nil {
|
||||
return ctx.NotFound("File not found")
|
||||
}
|
||||
|
||||
contentType := handlers.GetContentTypeFromFilename(file.Filename)
|
||||
ctx.Response().Header().Set("Content-Type", contentType)
|
||||
return ctx.PlainText(200, file.Content)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user