Skip to content

Commit

Permalink
added condition: pdf as text
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho committed Jul 10, 2023
1 parent d32a251 commit cfe5abe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Products/zms/_blobfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit cfe5abe

Please sign in to comment.