knotserver: also serve text/plain in BlobRaw #388

merged
opened by anirudh.fi targeting master from push-svtkmrzmrwky
Changed files
+11 -3
knotserver
+11 -3
knotserver/routes.go
···
mimeType = "image/svg+xml"
}
-
if !strings.HasPrefix(mimeType, "image/") && !strings.HasPrefix(mimeType, "video/") {
-
l.Error("attempted to serve non-image/video file", "mimetype", mimeType)
-
writeError(w, "only image and video files can be accessed directly", http.StatusForbidden)
+
// allow image, video, and text/plain files to be served directly
+
switch {
+
case strings.HasPrefix(mimeType, "image/"):
+
// allowed
+
case strings.HasPrefix(mimeType, "video/"):
+
// allowed
+
case strings.HasPrefix(mimeType, "text/plain"):
+
// allowed
+
default:
+
l.Error("attempted to serve disallowed file type", "mimetype", mimeType)
+
writeError(w, "only image, video, and text files can be accessed directly", http.StatusForbidden)
return
}