meta data for this page
Download a User's File
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.
- Method: GET
- Target: https://api.ensims.com/jea_web/api/download/<file ID>
- Header: Authorization “Bearer <existing JWT>”
- Body: none
- Success: File content
- Error: HTTP 401 - Unauthorized, HTTP 404 Not found
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)