Skip to content

Commit

Permalink
fix: add preview bypass for .gif files (#1012)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Fritzsche committed Jul 7, 2020
1 parent b1605aa commit 453636d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions http/preview.go
Expand Up @@ -59,6 +59,19 @@ func handleImagePreview(w http.ResponseWriter, r *http.Request, file *files.File
return errToStatus(err), err
}

fd, err := file.Fs.Open(file.Path)
if err != nil {
return errToStatus(err), err
}
defer fd.Close()

if format == imaging.GIF && size == sizeBig {
if _, err := rawFileHandler(w, r, file); err != nil { //nolint: govet
return errToStatus(err), err
}
return 0, nil
}

var imgProcessor imageProcessor
switch size {
case sizeBig:
Expand All @@ -73,12 +86,6 @@ func handleImagePreview(w http.ResponseWriter, r *http.Request, file *files.File
return http.StatusBadRequest, fmt.Errorf("unsupported preview size %s", size)
}

fd, err := file.Fs.Open(file.Path)
if err != nil {
return errToStatus(err), err
}
defer fd.Close()

img, err := imaging.Decode(fd, imaging.AutoOrientation(true))
if err != nil {
return errToStatus(err), err
Expand Down

0 comments on commit 453636d

Please sign in to comment.