Download
Transfers the file from path as an attachment
.
Typically, browsers will prompt the user to download. By default, the Content-Disposition header filename=
parameter is the file path (this typically appears in the browser dialog).
Override this default with the filename parameter.
c.Download(path, filename ...string) error
app.Get("/", func(c *fiber.Ctx) {
if err := c.Download("./files/report-12345.pdf"); err != nil {
c.Next(err) // Pass err to fiber
}
// => Download report-12345.pdf
if err := c.Download("./files/report-12345.pdf", "report.pdf"); err != nil {
c.Next(err) // Pass err to fiber
}
// => Download report.pdf
})