Okay so basically i have built a function to get the download URL for the specified ref which can be found below:
function download_file(val) { //val = Uploa