[Mayan EDMS: 1715] Download document via API

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 1715] Download document via API

Lucas Riccombene
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 /api/documents/documents/{pk}/download




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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 1716] Re: Download document via API

rosarior
Administrator
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



<a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="padding-top:7px;padding-bottom:4px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:0.7em;line-height:inherit;font-family:inherit;vertical-align:baseline;color:white;text-transform:uppercase;display:inline-block;width:50px;text-align:center;border-radius:2px;background-color:rgb(15,106,180)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">T <a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:black" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">/api/documents/documents/{pk}/download




Esto es correcto

api = API(host='<a href="http://10.0.0.102" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;">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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 1725] Re: Download document via API

Lucas Riccombene
Hola roberto ,  consulta tema descargar documentos:  
con esta linea  file_object.write(str(api.documents.documents(13).download.get()))
retorna el string de la memoria en el archivo creado  (tP\xf0\x16\xf6\xf9\xd4\x95\xc6\x85\xb3\x03M\xe6\xcb\x90\n\x05\x0bSC\x8f\x85\\\x0c7\x139\xa0O\x01\x95\x02\x07\x87\xb7\xe4o\x14\xfa\x96C\xed.\xa8C\xf4\x18\xd7\xfc\xb6\xb5\xde\x1d\x84\xda\xd5`\x02\x99\xecI\xa2t.\xaa\xe7\x99\xaa(\xadC\xa5\x9a\xb4]\xa8\x96d\x9e\x8bZ\xcd\xe0\xc7\xb9\xcd5\x06\x89i\xe0rl\xb6\xe2\xee\xb2\xcf)]\xf69\xe6\x86\xd3M\xd9\xd4\r]\x17;\x9e\x948\xb7\xc0F6\x11A\x03$[ \xa6.WLw\xc3X\xca2\xe1J6@\xe4\xba\xb1\xb9\x9e.\xe6-I\xdc^\xa4\x83\x9c\xe8_:\xb5\x99\xe0\xb5\x13\xe2\xa7\xff\x80\x00\t\'\x8d^#?\xee\xe9\xee\x14\xc0f\xbe\x11_d\x93\'\xbb\xb7\x87\x91\x00752\x83!)

si utilizo esta linea : 
file_object.write(api.documents.documents(13).download.get())
TypeError: write () argumento debe str, no bytes

Saludos


El viernes, 19 de mayo de 2017, 15:59:49 (UTC-3), Roberto Rosario escribió:
Here is an example on how to download document from the online demo:

from mayan_api_client import API

api = API(host='<a href="http://demo.mayan-edms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdemo.mayan-edms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGD0RK6Q2l7qZCoxk21AAFpgGDrtQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdemo.mayan-edms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGD0RK6Q2l7qZCoxk21AAFpgGDrtQ&#39;;return true;">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



<a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="padding-top:7px;padding-bottom:4px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:0.7em;line-height:inherit;font-family:inherit;vertical-align:baseline;color:white;text-transform:uppercase;display:inline-block;width:50px;text-align:center;border-radius:2px;background-color:rgb(15,106,180)" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">T <a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:black" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">/api/documents/documents/{pk}/download




Esto es correcto

api = API(host='<a href="http://10.0.0.102" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;">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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 1726] Re: Download document via API

Lucas Riccombene
Hola a todos , bueno ya lo resolvi era un problema del metado python que estaba utilizando 
la correcionfinal es asi, el problema estaba en esta linea  with open(document['label'], 'wb') as file_object: antes tenia w+
  def descargar(self):
        #pyqtRemoveInputHook()
        #import pdb; pdb.set_trace()
        # Obtener datos del documento
        #print 'Obteniendo datos del document #:', document_id
        document = api.documents.documents(13).get()
        #print 'Nombre de archivo del documento:', document['label']
        #print 'Descargando...'
        # Crear un archivo para escritura come el mismo nombre del documento a descargar
        with open(document['label'], 'wb') as file_object:
            #file_object.write(api.documents.documents(4).download.get())
            id= self.id_descarga.text()
            file_object.write(api.documents.documents(13).download.get())

        file_object.close()


El lunes, 22 de mayo de 2017, 15:19:13 (UTC-3), Lucas Riccombene escribió:
Hola roberto ,  consulta tema descargar documentos:  
con esta linea  file_object.write(str(api.documents.documents(13).download.get()))
retorna el string de la memoria en el archivo creado  (tP\xf0\x16\xf6\xf9\xd4\x95\xc6\x85\xb3\x03M\xe6\xcb\x90\n\x05\x0bSC\x8f\x85\\\x0c7\x139\xa0O\x01\x95\x02\x07\x87\xb7\xe4o\x14\xfa\x96C\xed.\xa8C\xf4\x18\xd7\xfc\xb6\xb5\xde\x1d\x84\xda\xd5`\x02\x99\xecI\xa2t.\xaa\xe7\x99\xaa(\xadC\xa5\x9a\xb4]\xa8\x96d\x9e\x8bZ\xcd\xe0\xc7\xb9\xcd5\x06\x89i\xe0rl\xb6\xe2\xee\xb2\xcf)]\xf69\xe6\x86\xd3M\xd9\xd4\r]\x17;\x9e\x948\xb7\xc0F6\x11A\x03$[ \xa6.WLw\xc3X\xca2\xe1J6@\xe4\xba\xb1\xb9\x9e.\xe6-I\xdc^\xa4\x83\x9c\xe8_:\xb5\x99\xe0\xb5\x13\xe2\xa7\xff\x80\x00\t\'\x8d^#?\xee\xe9\xee\x14\xc0f\xbe\x11_d\x93\'\xbb\xb7\x87\x91\x00752\x83!)

si utilizo esta linea : 
file_object.write(api.documents.documents(13).download.get())
TypeError: write () argumento debe str, no bytes

Saludos


El viernes, 19 de mayo de 2017, 15:59:49 (UTC-3), Roberto Rosario escribió:
Here is an example on how to download document from the online demo:

from mayan_api_client import API

api = API(host='<a href="http://demo.mayan-edms.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdemo.mayan-edms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGD0RK6Q2l7qZCoxk21AAFpgGDrtQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdemo.mayan-edms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGD0RK6Q2l7qZCoxk21AAFpgGDrtQ&#39;;return true;">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



<a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="padding-top:7px;padding-bottom:4px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:0.7em;line-height:inherit;font-family:inherit;vertical-align:baseline;color:white;text-transform:uppercase;display:inline-block;width:50px;text-align:center;border-radius:2px;background-color:rgb(15,106,180)" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">T <a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:black" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">/api/documents/documents/{pk}/download




Esto es correcto

api = API(host='<a href="http://10.0.0.102" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;">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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 1733] Re: Download document via API

rosarior
Administrator
Gracias por el feedback! Exito!

On Monday, May 22, 2017 at 2:53:56 PM UTC-4, Lucas Riccombene wrote:
Hola a todos , bueno ya lo resolvi era un problema del metado python que estaba utilizando 
la correcionfinal es asi, el problema estaba en esta linea  with open(document['label'], 'wb') as file_object: antes tenia w+
  def descargar(self):
        #pyqtRemoveInputHook()
        #import pdb; pdb.set_trace()
        # Obtener datos del documento
        #print 'Obteniendo datos del document #:', document_id
        document = api.documents.documents(13).get()
        #print 'Nombre de archivo del documento:', document['label']
        #print 'Descargando...'
        # Crear un archivo para escritura come el mismo nombre del documento a descargar
        with open(document['label'], 'wb') as file_object:
            #file_object.write(api.documents.documents(4).download.get())
            id= self.id_descarga.text()
            file_object.write(api.documents.documents(13).download.get())

        file_object.close()


El lunes, 22 de mayo de 2017, 15:19:13 (UTC-3), Lucas Riccombene escribió:
Hola roberto ,  consulta tema descargar documentos:  
con esta linea  file_object.write(str(api.documents.documents(13).download.get()))
retorna el string de la memoria en el archivo creado  (tP\xf0\x16\xf6\xf9\xd4\x95\xc6\x85\xb3\x03M\xe6\xcb\x90\n\x05\x0bSC\x8f\x85\\\x0c7\x139\xa0O\x01\x95\x02\x07\x87\xb7\xe4o\x14\xfa\x96C\xed.\xa8C\xf4\x18\xd7\xfc\xb6\xb5\xde\x1d\x84\xda\xd5`\x02\x99\xecI\xa2t.\xaa\xe7\x99\xaa(\xadC\xa5\x9a\xb4]\xa8\x96d\x9e\x8bZ\xcd\xe0\xc7\xb9\xcd5\x06\x89i\xe0rl\xb6\xe2\xee\xb2\xcf)]\xf69\xe6\x86\xd3M\xd9\xd4\r]\x17;\x9e\x948\xb7\xc0F6\x11A\x03$[ \xa6.WLw\xc3X\xca2\xe1J6@\xe4\xba\xb1\xb9\x9e.\xe6-I\xdc^\xa4\x83\x9c\xe8_:\xb5\x99\xe0\xb5\x13\xe2\xa7\xff\x80\x00\t\'\x8d^#?\xee\xe9\xee\x14\xc0f\xbe\x11_d\x93\'\xbb\xb7\x87\x91\x00752\x83!)

si utilizo esta linea : 
file_object.write(api.documents.documents(13).download.get())
TypeError: write () argumento debe str, no bytes

Saludos


El viernes, 19 de mayo de 2017, 15:59:49 (UTC-3), Roberto Rosario escribió:
Here is an example on how to download document from the online demo:

from mayan_api_client import API

api = API(host='<a href="http://demo.mayan-edms.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdemo.mayan-edms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGD0RK6Q2l7qZCoxk21AAFpgGDrtQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdemo.mayan-edms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGD0RK6Q2l7qZCoxk21AAFpgGDrtQ&#39;;return true;">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



<a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="padding-top:7px;padding-bottom:4px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:0.7em;line-height:inherit;font-family:inherit;vertical-align:baseline;color:white;text-transform:uppercase;display:inline-block;width:50px;text-align:center;border-radius:2px;background-color:rgb(15,106,180)" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">T <a href="http://10.0.0.102/docs/#!/documents/Api_Document_Download_GET" style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:black" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102%2Fdocs%2F%23!%2Fdocuments%2FApi_Document_Download_GET\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG04eJgJLOtzKvatqows_I6vR8ODw&#39;;return true;">/api/documents/documents/{pk}/download




Esto es correcto

api = API(host='<a href="http://10.0.0.102" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F10.0.0.102\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7Mf0oZUEW4uBJpditWPLKwUV_2g&#39;;return true;">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 [hidden email].
For more options, visit https://groups.google.com/d/optout.