MCPcopy Create free account
hub / github.com/BryanMwangi/pine / StreamFile

Method StreamFile

file.go:97–114  ·  view source on GitHub ↗
(filePath string)

Source from the content-addressed store, hash-verified

95}
96
97func (c *Ctx) StreamFile(filePath string) error {
98 file, err := os.Open(filePath)
99 if err != nil {
100 fmt.Println(err)
101 return c.SendStatus(http.StatusInternalServerError)
102 }
103 defer file.Close()
104
105 fileInfo, err := file.Stat()
106 if err != nil {
107 fmt.Println(err)
108 return c.SendStatus(http.StatusInternalServerError)
109 }
110 modTime := fileInfo.ModTime()
111
112 http.ServeContent(c.Response.ResponseWriter, c.Request, filePath, modTime, file)
113 return nil
114}

Callers 1

mainFunction · 0.80

Calls 1

SendStatusMethod · 0.95

Tested by

no test coverage detected