SendFileWithRate same as `SendFile` but it can throttle the speed of reading and though writing the file to the client.
(src, destName string, limit float64, burst int)
| 5517 | // SendFileWithRate same as `SendFile` but it can throttle the speed of reading |
| 5518 | // and though writing the file to the client. |
| 5519 | func (ctx *Context) SendFileWithRate(src, destName string, limit float64, burst int) error { |
| 5520 | if destName == "" { |
| 5521 | destName = filepath.Base(src) |
| 5522 | } |
| 5523 | |
| 5524 | ctx.writer.Header().Set(ContentDispositionHeaderKey, MakeDisposition(destName)) |
| 5525 | return ctx.ServeFileWithRate(src, limit, burst) |
| 5526 | } |
| 5527 | |
| 5528 | // MakeDisposition generates an HTTP Content-Disposition field-value. |
| 5529 | // Similar solution followed by: Spring(Java), Symfony(PHP) and Ruby on Rails frameworks too. |
no test coverage detected