meta data for this page

Download a User's File

Back to JEA API docs


Files that have been uploaded by the user to the JEA service can be downloaded with the auto-generated file ID. A valid JWT token must be included in the header, or the transaction will be rejected with an HTTP 401 Unauthorized error code.


Synopsis

Example using curl://

To download the file with ID command using curl:

curl -b cookies   https://api.ensims.com/jea_web/api/download/d07b790c956e0fa5036b420edce2f5f0 > dn.png

On successful operation, the contents of the requested file is returned. If the existing JWT is invalid, an HTTP 401 Unauthorized code will be returned.

Example using Python Requests

Make sure Requests is correctly installed in your Python environment, and run the following the lines:

import requests

# Make a request with the stored cookies from the log on transaction

# Download a previously uploaded file. The example is a png image
r = requests.get('https://api.ensims.com/jea_web/api/download/d07b790c956e0fa5036b420edce2f5f0', cookies=cookies, stream=True)

# Write downloaded file content to disk using the given file name
filename = 'dn.png'
with open(filename, 'wb') as fd:
    for chunk in r.iter_content(chunk_size=128):
        fd.write(chunk)