logo

Downloading Media Files

An incoming message carries a media id, not the bytes. Download the bytes over HTTPS with that id.
💡 Every SDK ships a MediaTransfer helper that downloads straight to a file. Reach for the raw HTTP below only if you are not using an SDK.

SDKs

SDK
Call
Java
MediaTransfer.downloadFile(token, mediaFileId, "./download", fileName, downloadServerURL);
JavaScript
MediaTransfer.downloadFile(token, mediaFileId, "./download", fileName, downloadServerURL);
Python
MediaTransfer.download_file(token, media_file_id, "./download", file_name, download_server_url)
Java returns 0 when the file was saved successfully.

Raw HTTP

GET https://<nandboxBotServer>:<port>/nandbox/download/<media_id>
For example: https://w1.nandbox.net:8080/nandbox/download/123456789.jpg

Headers

Header
Value
Content-Type
application/json
X-Token
Your bot token.
media_id is the id from the Media Object on the incoming message.

Responses

Status
Body
🟢 200
The raw binary content of the file.
🔴 404
{ "message": "Not Found" }