Saving .hex file to SD card

Hi there,
I got another device connected to G120 through UART, which can download .hex from server, I am not sure how can I transfer that to G120 and save it to SD card, is there any examples for that ?
Basically, I wanted to do that for infield update, so would like to save file first on sdcard. So , how can I transfer from one device to G120 over the UART and save it to Sdcard ?