From 04d3e5d97740fdc26817fbd99442c92c53f44034 Mon Sep 17 00:00:00 2001
From: Daniel Neuwirth <daniel.neuwirth@dataport.de>
Date: Fri, 6 Dec 2019 07:52:11 +0000
Subject: [PATCH] c

---
 ckanext/odsh/pdf_to_thumbnail/thumbnail.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ckanext/odsh/pdf_to_thumbnail/thumbnail.py b/ckanext/odsh/pdf_to_thumbnail/thumbnail.py
index 1a00f23d..8a7a6566 100644
--- a/ckanext/odsh/pdf_to_thumbnail/thumbnail.py
+++ b/ckanext/odsh/pdf_to_thumbnail/thumbnail.py
@@ -86,6 +86,10 @@ def create_thumbnail_from_url(resource, private):
     #log.debug(response)
     if response:
         body = response.read()
+        
+        encoding = response.info().getencoding()
+        encoded_body = body.decode(encoding)
+        log.debug('encoded_body mime: {}'.format(magic.from_buffer(encoded_body, mime = True)))
         body_decoded = body.decode('utf-8')
         log.debug('body_decoded mime: {}'.format(magic.from_buffer(body_decoded, mime = True)))
         body_encoded = body.body_encoded('utf-8')
@@ -94,6 +98,13 @@ def create_thumbnail_from_url(resource, private):
         memory_file = io.BytesIO(response.read())
         log.debug('memory_file mime: {}'.format(magic.from_buffer(memory_file.read(), mime = True)))
         
+        log.debug('response is not None')
+        log.debug('response: {}'.format(response.read()))
+        temp_path = config.get('ckan.storage_path') + '/resources/' + 'temp_for_thumbnail'
+        log.debug('body_encoded mime: {}'.format(magic.from_buffer(body_decoded, mime = True)))
+        memory_file = io.BytesIO(response.read())
+        log.debug('memory_file mime: {}'.format(magic.from_buffer(memory_file.read(), mime = True)))
+        
         log.debug('response is not None')
         log.debug('response: {}'.format(response.read()))
         temp_path = config.get('ckan.storage_path') + '/resources/' + 'temp_for_thumbnail'
-- 
GitLab