Skip to content

Commit 5b3d50f

Browse files
authored
Merge pull request juruen#103 from ddvk/thumbnails_optional
quickfix to make thumbnails optional
2 parents 67758be + dc94c85 commit 5b3d50f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,6 @@ rMAPI will set the exit code to `0` if the command succeedes, or `1` if it fails
177177
- `RMAPI_CONFIG`: filepath used to store authentication tokens. When not set, rmapi uses the file `.rmapi` in the home directory of the current user.
178178
- `RMAPI_TRACE=1`: enable trace logging.
179179
- `RMAPI_USE_HIDDEN_FILES=1`: use and traverse hidden files/directories (they are ignored by default).
180+
- `RMAPI_THUMBNAILS`: generate a thumbnail of the first page of a pdf document
181+
- `RMAPI_AUTH`: override the default authorization url
182+
- `RMAPI_DOC`: override the default document storage url

util/zipdoc.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"image/jpeg"
88
"io/ioutil"
9+
"os"
910
"strings"
1011

1112
"bytes"
@@ -28,7 +29,6 @@ type zipDocumentContent struct {
2829
}
2930

3031
func makeThumbnail(pdf []byte) ([]byte, error) {
31-
3232
reader, err := model.NewPdfReader(bytes.NewReader(pdf))
3333
if err != nil {
3434
return nil, err
@@ -88,7 +88,8 @@ func CreateZipDocument(id, srcPath string) (string, error) {
8888
f.Write(pdf)
8989

9090
//try to create a thumbnail
91-
if ext == "pdf" {
91+
//due to a bug somewhere in unipdf the generation is opt-in
92+
if ext == "pdf" && os.Getenv("RMAPI_THUMBNAILS") != "" {
9293
thumbnail, err := makeThumbnail(pdf)
9394
if err != nil {
9495
log.Error.Println("cannot generate thumbnail", err)

0 commit comments

Comments
 (0)