From cfe5abe1dd9afc0361fbc35e0b5983c9b4c80cce Mon Sep 17 00:00:00 2001 From: drfho Date: Mon, 10 Jul 2023 12:37:02 +0200 Subject: [PATCH] added condition: pdf as text --- Products/zms/_blobfields.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Products/zms/_blobfields.py b/Products/zms/_blobfields.py index d79cbddb1..19df51357 100644 --- a/Products/zms/_blobfields.py +++ b/Products/zms/_blobfields.py @@ -146,9 +146,12 @@ def createBlobField(self, objtype, file=b''): elif isinstance(file, dict): data = file.get( 'data', '') if isinstance(data, str): - # data = bytes(data,'utf-8') - # data = io.BytesIO( data) - data = io.StringIO ( data) + if file.get('content_type') == 'application/pdf': + # PDFs are stored as text, e.g. pdfmake.js (DESY/v22) + data = io.StringIO ( data) + else: + data = bytes(data,'utf-8') + data = io.BytesIO( data) blob = uploadBlobField( self, objtype, data, file.get('filename', '')) if file.get('content_type'): blob.content_type = file.get('content_type')