diff --git a/ckanext/odsh/pdf_to_thumbnail/thumbnail.py b/ckanext/odsh/pdf_to_thumbnail/thumbnail.py index 1a00f23dcadb687da98d040a200daa4706b7ae26..8a7a65660ecab3199f0db6c00a28fb8fafc1b01d 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'