Skip to content

Commit

Permalink
Setting video files MIME type
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Dec 31, 2023
1 parent feef17a commit 746555e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rest/get_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package rest

import (
"github.com/boggydigital/yet/paths"
"github.com/boggydigital/yt_urls"
"net/http"
"os"
"path/filepath"
"strings"
)

func GetVideo(w http.ResponseWriter, r *http.Request) {
Expand All @@ -24,6 +26,9 @@ func GetVideo(w http.ResponseWriter, r *http.Request) {
absFilepath := filepath.Join(absVideosDir, file)

if _, err := os.Stat(absFilepath); err == nil {
if strings.HasSuffix(file, yt_urls.DefaultVideoExt) {
w.Header().Set("Content-Type", "video/mp4")
}
http.ServeFile(w, r, absFilepath)
} else {
http.NotFound(w, r)
Expand Down

0 comments on commit 746555e

Please sign in to comment.