Here is an example on how to download document from the online demo:

from mayan_api_client import API

api = API(host='http://demo.mayan-edms.com', username='admin', 
password='demo1234')

document_id = 452

# Get document properties
print 'Properties of document #:', document_id
document = api.documents.documents(document_id).get()

print 'Label (filename) of document:', document['label']
print 'Downloading...'

with open(document['label'], 'w+') as file_object:
    file_object.write(api.documents.documents(document_id).download.get())


On Friday, May 19, 2017 at 12:52:25 PM UTC-4, Lucas Riccombene wrote:

> Hola Roberto, necesitaria descargar via la api un documento, esta 
> funcionalidad existe en la api
> Alguien tiene un ejemplo de como usar la api para descargar un documento
> Download original document via API.
> Creo que esto lo responde pero no entiendo como llamar a la api para 
> descarga pongo ejemplo
>
>
> T <http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET> 
> /api/documents/documents/{pk}/download 
> <http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET>
>
>
>
> Esto es correcto
>
> api = API(host='http://10.0.0.102', username='admin', password='slam2016')
> respose =api.documents.documents.download(1)
>
> Ejemplo para guardar documento correcto
> .....
>         with 
> codecs.open('/home/user/Documentos/ALTEC/sgd20170513/tmp/prueba.pdf', 
> "r",encoding='utf-8', errors='ignore') as file_object:
>         #with 
> open('/home/user/Documentos/ALTEC/sgd20170513/tmp/test_document.pdf') as 
> file_object:
>             response = api.documents.documents.post({'document_type': 2}, 
> files={'file': file_object})
>
>         self.obj_form.lbl_id.setText(str(response['id']))
> ........
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to