(filePath string)
| 95 | } |
| 96 | |
| 97 | func (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 | } |