Skip to content
Snippets Groups Projects
Commit b83644f3 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Ensure file-like objects are opened in binary mode for XML uploads

parent a072d8a5
No related tags found
No related merge requests found
Pipeline #28170 passed
......@@ -201,7 +201,7 @@ Import transcriptions for a page from files in PAGE XML format
.. code:: python
cli.send_xml('ImportTranskribusTranscriptions', id='PAGE_ID', body=open('file.xml'))
cli.send_xml('ImportTranskribusTranscriptions', id='PAGE_ID', body=open('file.xml', 'rb'))
Download full logs for each Ponos task in a workflow
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
......@@ -8,6 +8,7 @@ import yaml
from arkindex.auth import TokenSessionAuthentication
from arkindex.pagination import ResponsePaginator
from arkindex.encoders import XMLEncoder
from io import FileIO
from time import sleep
from urllib.parse import urlsplit, urlunsplit
......@@ -178,9 +179,13 @@ class ArkindexClient(apistar.Client):
:param str operation_id: An OpenAPI operation ID.
:param body: The XML body.
:type body: str or bytes
:type body: str, bytes or a file-like object opened in binary mode
:param kwargs: Other arguments sent to :meth:`ArkindexClient.custom_request`.
"""
if isinstance(body, FileIO):
assert body.mode == 'rb', 'File-like objects should be opened in binary mode'
return self.custom_request(
operation_id,
content=body,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment