- 14 Nov 2024
- 1 Minute to read
- Print
- DarkLight
Media
- Updated on 14 Nov 2024
- 1 Minute to read
- Print
- DarkLight
Media saved using an external-media-id on the EdgeFlow can be retrieved via the following API.
GET /1/media/{external_media_id}
HOST: http://<gateway ip address or hostname>:8000
Responses:
The response will be in a JSON-encoded format with the following fields:
Name | Description |
---|---|
media_type string | "image" or "video" |
media_bytes string | base64 encoded JPEG image. |
media_md5 string | the MD5 checksum of the base64 encoded image |
created_at float | the timestamp of when media was generated. |
external_media_id string | external-media-id associated with this image |
domain_unit string | If available, the domain unit associated with the media. |
The response status code can be one of the following:
Status Code | Description |
---|---|
200 | Image included in json response message |
404 | Media not available. If this is the case, a retry should be performed as there are situations where newly created media may not be immediately available . |
500 | Timeout processing request - no response from backend storage system. |
API Usage example:
import requests
import base64
API_VERSION = 1
URL_PREFIX = 'http://10.10.1.199:8000/%d/' % API_VERSION
TIMEOUT= 30 # seconds for response
def get_media(external_media_id):
resp = requests.get(URL_PREFIX + 'media/%s' % external_media_id,
timeout=TIMEOUT)
if resp.status_code == 200:
media_data = resp.json()
img = base64.b64decode(media_data['media_bytes'])
with open('/tmp/%s.jpg' % external_media_id, 'wb') as fh:
fh.write(img)