Automatic download of a file stored as BLOB in MySQL from ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi everyone,
I’m working on a scenario where files are stored as BLOBs in an external MySQL database. The requirement is to allow users to download these files directly to their local machine from ServiceNow, without saving the file in ServiceNow itself, due to storage limitations.
The workflow would be something like:
ServiceNow retrieves the file in BLOB format from MySQL.
The file is sent to the user’s browser.
The browser automatically triggers the download on the operator’s PC.
I’m wondering if anyone has experience with:
Retrieving BLOB data from an external database and streaming it to the client from ServiceNow.
Triggering an automatic download in the browser without creating a ServiceNow attachment.
Any guidance, best practices, or examples would be greatly appreciated.
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @FrancescoP ,
I haven't implemented this functionality but I have few suggestions how we can achieve this. We can implement this using below method:
ServiceNow sends a request to a MID Server Script (or IntegrationHub action) to fetch the BLOB from MySQL. If you're using a MID Server, create a Script Include that runs on the MID Server to fetch the file. Alternatively, you could use a JDBC Data Source + Scripted Import, but it's less flexible for dynamic retrieval
The MID Server retrieves the BLOB and returns it to ServiceNow as a Base64-encoded string (to safely transmit binary over JSON). Create a Scripted REST API that returns the file to the browser.
A Scripted REST API in ServiceNow receives the Base64 data, sets the correct response headers (e.g., Content-Disposition), and sends it to the client’s browser. You can use a UI Script or Service Portal Widget to trigger the file download.
A front-end UI action or widget triggers this download by hitting the Scripted REST endpoint and auto-initiating the download. Call downloadFile('some_file_id'); on a button click or UI Action.