Esempio n. 1
0
 def _ajax_get_binary(self, mime_type, uid):
     mime_type = mime_type.replace('_', '/')
     div = '<div style="display: block; border: 1px solid; border-color: #dddddd; padding: 5px; text-align: center">'
     with ConnectTo(InterComFrontEndBinding, self._config) as sc:
         binary = sc.get_binary_and_filename(uid)[0]
     if 'text/' in mime_type:
         return '<pre style="white-space: pre-wrap">{}</pre>'.format(
             html.escape(bytes_to_str_filter(binary)))
     if 'image/' in mime_type:
         return '{}<img src="data:image/{} ;base64,{}" style="max-width:100%"></div>'.format(
             div, mime_type[6:], encode_base64_filter(binary))
     return None
Esempio n. 2
0
def test_base64_filter():
    assert encode_base64_filter(b'test') == 'dGVzdA=='