saving work

This commit is contained in:
Xuu
2020-10-26 12:39:08 -06:00
parent 1a88e47181
commit db4ac49a49
9 changed files with 93 additions and 221 deletions

View File

@@ -15,6 +15,8 @@ import (
"github.com/h2non/filetype"
"sour.is/x/toolbox/httpsrv"
"sour.is/x/toolbox/log"
"sour.is/x/paste/src/pkg/readutil"
)
func init() {
@@ -81,7 +83,7 @@ func (a *Image) get(w http.ResponseWriter, r *http.Request) {
}
defer f.Close()
pr := NewPreviewReader(f)
pr := readutil.NewPreviewReader(f)
mime, err := ReadMIME(pr, name)
w.Header().Set("Content-Type", mime)
@@ -105,7 +107,7 @@ func (a *Image) put(w http.ResponseWriter, r *http.Request) {
}
rdr := io.LimitReader(r.Body, a.maxSize)
pr := NewPreviewReader(rdr)
pr := readutil.NewPreviewReader(rdr)
if !isImageOrVideo(pr) {
httpsrv.WriteError(w, http.StatusUnsupportedMediaType, "ERR Not Image")
return