It wouldn’t be possible to do this via a script in the sandbox environment but you could probably achieve that using Newman.
You could create a Newman script that runs the request and downloads the file to your file system.
These are some example of writing files to disk that could be adapted for your usecase.