Factor out duplicated code

Create a new download utility method to contain the previously
duplicated code.

[#54205148]
Merge 54205148-code_climate to master

[#54205148]