ewsterrenburg / python-otrs

Pythonic interface to OTRS SOAP API
GNU General Public License v3.0
47 stars 27 forks source link

base64 encoding for attachments with Python 3 #47

Open vincentborghi opened 3 years ago

vincentborghi commented 3 years ago

The example given in the documentation: att_content = base64.b64encode(att_file.read()) does not work, because the content string in the generated XML has a leading literal "b" and is enclosed with quotes (b'XXXXX' instead of just XXXXX). As a result, the contents is stored in OTRS but unreadable due to those unwanted characters.

As a workaround, I was obliged to do: att_content = base64.b64encode(att_file.read()).decode('utf-8')

But the root cause of this is probably a bug in the way "unicode" function is defined in client.py when using python 3.

ewsterrenburg commented 2 years ago

Not sure yet if it's indeed related to this "unicode" function, however docs should be correct of course. I'm leaning towards scrapping Python 2 compatibility altogether and simplify some of these things.