Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
set behavior, clicking file to download directly
Browse files Browse the repository at this point in the history
  • Loading branch information
finzzz committed May 24, 2021
1 parent b030048 commit c7f2adf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (h HandlerObj) Handler(w http.ResponseWriter, r *http.Request) {
return
}

w.Header().Set("Content-Disposition", "attachment")
http.ServeFile(w, r, h.Config.Dir + link)
}

Expand All @@ -74,7 +75,7 @@ func (h HandlerObj) uploadHandler(w http.ResponseWriter, r *http.Request){
return
}

fileBytes, err := io.ReadAll(file) // read content
fileBytes, _ := io.ReadAll(file) // read content
err = os.WriteFile( h.Config.Dir + r.RequestURI + fileHeader.Filename, fileBytes, 0644) // write to file
if logger.LogErr("uploadHandler", err) {
return
Expand Down Expand Up @@ -153,8 +154,6 @@ func (h HandlerObj) zipHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Disposition", "attachment; filename=" + utils.Basename(link) + ".zip")
http.ServeFile(w, r, z)
_ = os.Remove(z)

return
}

func (h HandlerObj) staticHandler(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit c7f2adf

Please sign in to comment.