try a limiter here

This commit is contained in:
Ted Unangst 2019-10-03 01:17:43 -04:00
parent e98366ccb7
commit 341577c35c
1 changed files with 5 additions and 1 deletions

View File

@ -149,9 +149,13 @@ func savedonk(url string, name, desc, media string, localize bool) *Donk {
goto saveit goto saveit
} }
var buf bytes.Buffer var buf bytes.Buffer
io.Copy(&buf, resp.Body) limiter := io.LimitReader(resp.Body, 10 * 1024 * 1024)
io.Copy(&buf, limiter)
data = buf.Bytes() data = buf.Bytes()
if len(data) == 10 * 1024 * 1024 {
log.Printf("truncation likely")
}
if strings.HasPrefix(media, "image") { if strings.HasPrefix(media, "image") {
img, err := image.Vacuum(&buf, img, err := image.Vacuum(&buf,
image.Params{LimitSize: 4800 * 4800, MaxWidth: 2048, MaxHeight: 2048}) image.Params{LimitSize: 4800 * 4800, MaxWidth: 2048, MaxHeight: 2048})