diff --git a/server/bog.go b/server/bog.go index 053fde8..e5e6afd 100644 --- a/server/bog.go +++ b/server/bog.go @@ -62,7 +62,19 @@ func (b *Bog) fileHandler(w http.ResponseWriter, r *http.Request) { swamp_file, err := b.file_service.OpenOutFile(ref) if err == swampfile.ErrNotExists { - http.NotFound(w, r) + templ, err := template.ParseFiles("server/views/upload.html") + + if err != nil { + panic(err) + } + + w.WriteHeader(404) + err = templ.Execute(w, nil) + + if err != nil { + panic(err) + } + return } @@ -70,6 +82,7 @@ func (b *Bog) fileHandler(w http.ResponseWriter, r *http.Request) { panic(err) } b.logger.Info("Serving file '%s' of size %d from '%s'", ref.Path, swamp_file.Size(), ref.UserAgent) + w.Header().Set("Content-Disposition", "attachment") http.ServeContent(w, r, swamp_file.Path(), swamp_file.Modified(), swamp_file) case "POST": fallthrough diff --git a/server/views/upload.html b/server/views/upload.html new file mode 100644 index 0000000..c8ce6a4 --- /dev/null +++ b/server/views/upload.html @@ -0,0 +1,25 @@ + + +
+