How to save a stream of bytes in a file from an API Call?

This may help show how to do that.