saving work
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user