MCPcopy
hub / github.com/filebrowser/filebrowser / rawFileHandler

Function rawFileHandler

http/raw.go:226–239  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, file *files.FileInfo)

Source from the content-addressed store, hash-verified

224}
225
226func rawFileHandler(w http.ResponseWriter, r *http.Request, file *files.FileInfo) (int, error) {
227 fd, err := file.Fs.Open(file.Path)
228 if err != nil {
229 return http.StatusInternalServerError, err
230 }
231 defer fd.Close()
232
233 setContentDisposition(w, r, file)
234 w.Header().Add("Content-Security-Policy", `script-src 'none';`)
235 w.Header().Set("X-Content-Type-Options", "nosniff")
236 w.Header().Set("Cache-Control", "private")
237 http.ServeContent(w, r, file.Name, file.ModTime, fd)
238 return 0, nil
239}

Callers 3

handleImagePreviewFunction · 0.85
public.goFile · 0.85
raw.goFile · 0.85

Calls 3

setContentDispositionFunction · 0.85
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected