<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Nuxeo API Python client attachBlob, encode error ? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/nuxeo-api-python-client-attachblob-encode-error/m-p/315843#M2844</link>
    <description>&lt;P&gt;Great ! To add in the &lt;A href="http://doc.nuxeo.com/x/pgA7"&gt;python client documentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
    <pubDate>Fri, 21 Feb 2014 16:57:28 GMT</pubDate>
    <dc:creator>SylvainD_</dc:creator>
    <dc:date>2014-02-21T16:57:28Z</dc:date>
    <item>
      <title>Nuxeo API Python client attachBlob, encode error ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/nuxeo-api-python-client-attachblob-encode-error/m-p/315841#M2842</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I find the correct method to attach a blob with the python automation client (&lt;A href="http://answers.nuxeo.com/questions/5293/how-to-call-blobattach-via-rest-api-in-python"&gt;answer how-to-call-blobattach-via-rest-api-in-python&lt;/A&gt;)&lt;BR /&gt; /&amp;gt;
Perfect for ascii files, but when i try to attach a blob like a pdf or a csv, I have an error UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 464: ordinal not in range(128)
I am on Ubuntu 12.04 / python 2.7.6 / Nuxeo 5.8&lt;/P&gt;
&lt;P&gt;Someone have an idea ?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Trace :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;ERROR:root:'ascii' codec can't decode byte 0xe9 in position 464: ordinal not in range(128)
Traceback (most recent call last):
File "perso_test2.py", line 21, in &amp;lt;module&amp;gt;
s.attachBlob(doc['uid'],'/home/administrateur/test3.csv')
File "/usr/local/lib/python2.7/dist-packages/nuxeo_automation-0.1-py2.7.egg/nuxeoautomation.py", line 93, in attachBlob
    return self._attach_blob(blob, document=ref)
  File "/usr/local/lib/python2.7/dist-packages/nuxeo_automation-0.1-py2.7.egg/nuxeoautomation.py", line 183, in _attach_blob
    resp = self.opener.open(req)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1174, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 812, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 464: ordinal not in range(128)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Feb 2014 15:26:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/nuxeo-api-python-client-attachblob-encode-error/m-p/315841#M2842</guid>
      <dc:creator>SylvainD_</dc:creator>
      <dc:date>2014-02-17T15:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Nuxeo API Python client attachBlob, encode error ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/nuxeo-api-python-client-attachblob-encode-error/m-p/315842#M2843</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would suggest you use the latest version of the Python Automation client available in the &lt;STRONG&gt;python-automation-client&lt;/STRONG&gt; branch of the &lt;A href="https://github.com/nuxeo/nuxeo-automation-clients"&gt;https://github.com/nuxeo/nuxeo-automation-clients&lt;/A&gt; repository:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/nuxeo/nuxeo-automation-clients/tree/python-automation-client/python"&gt;https://github.com/nuxeo/nuxeo-automation-clients/tree/python-automation-client/python&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This is the result of the extraction of the Python Automation client used by Nuxeo Drive, which we put in a branch for the moment as work is still in progress. You will find:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A README&lt;/LI&gt;
&lt;LI&gt;The Pyhton Automation client: automation_client.py&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If you want to attach a blob to an existing Nuxeo document, the following lines should do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;import automation_client
client = automation_client.BaseAutomationClient('http://server:port/nuxeo', 'usernamme', password='*****')
blob = client.execute_with_blob_streaming('Blob.Attach', '/path/to/the/file/to/upload/my_file.pdf', filename='my_file.pdf', document='/default-domain/workspaces/TestPython/TestPDFUpload')
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should solve your problem, and has the advantage of:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Using the latest Automation batch upload API (see &lt;A href="http://doc.nuxeo.com/x/OYLZ"&gt;http://doc.nuxeo.com/x/OYLZ&lt;/A&gt;) instead of a multipart POST&lt;/LI&gt;
&lt;LI&gt;Streaming the blob instead of fully loading it in memory!&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2014 15:06:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/nuxeo-api-python-client-attachblob-encode-error/m-p/315842#M2843</guid>
      <dc:creator>ataillefer_</dc:creator>
      <dc:date>2014-02-21T15:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Nuxeo API Python client attachBlob, encode error ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/nuxeo-api-python-client-attachblob-encode-error/m-p/315843#M2844</link>
      <description>&lt;P&gt;Great ! To add in the &lt;A href="http://doc.nuxeo.com/x/pgA7"&gt;python client documentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2014 16:57:28 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/nuxeo-api-python-client-attachblob-encode-error/m-p/315843#M2844</guid>
      <dc:creator>SylvainD_</dc:creator>
      <dc:date>2014-02-21T16:57:28Z</dc:date>
    </item>
  </channel>
</rss>

