raw and download urls working :D

This commit is contained in:
Henrique Dias
2016-06-11 22:07:55 +01:00
parent 42fdc14953
commit ba64a3df0f
2 changed files with 18 additions and 5 deletions

View File

@@ -64,10 +64,22 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
return ServeAssets(w, r, c)
}
/* if file.Info.IsDir() {
return f.ServeListing(w, r, file.File, c)
}
return f.ServeSingleFile(w, r, file, c) */
if fi.IsDir {
//return f.ServeListing(w, r, file.File, c)
}
query := r.URL.Query()
if val, ok := query["raw"]; ok && val[0] == "true" {
// wanna raw file
return f.Next.ServeHTTP(w, r)
}
if val, ok := query["download"]; ok && val[0] == "true" {
w.Header().Set("Content-Disposition", "attachment; filename="+fi.Name)
return f.Next.ServeHTTP(w, r)
}
// return f.ServeSingleFile(w, r, file, c)
case http.MethodPost:
// Upload a new file
if r.Header.Get("Upload") == "true" {