Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base64 encoding for attachments with Python 3 #47

Open
vincentborghi opened this issue Mar 15, 2021 · 1 comment
Open

base64 encoding for attachments with Python 3 #47

vincentborghi opened this issue Mar 15, 2021 · 1 comment

Comments

@vincentborghi
Copy link

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants