Skip to content
Snippets Groups Projects
Commit e0477938 authored by Dean's avatar Dean
Browse files

Merge branch 'add-download-param' into 'master'

Add a query param to force files to download

See merge request whats-this/cdn-origin!10
parents 021e3af1 26aae59b
No related branches found
No related tags found
No related merge requests found
...@@ -486,6 +486,9 @@ func requestHandler(ctx *fasthttp.RequestCtx) { ...@@ -486,6 +486,9 @@ func requestHandler(ctx *fasthttp.RequestCtx) {
} else { } else {
ctx.SetContentType("application/octet-stream") ctx.SetContentType("application/octet-stream")
} }
if ctx.QueryArgs().Has("download") {
ctx.Response.Header.Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, key))
}
ctx.Response.Header.Set("ETag", fmt.Sprintf(`"%s"`, *object.SHA256Hash)) ctx.Response.Header.Set("ETag", fmt.Sprintf(`"%s"`, *object.SHA256Hash))
fasthttp.ServeFileUncompressed(ctx, fPath) fasthttp.ServeFileUncompressed(ctx, fPath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment