save_media needs to handle nil uri

Sometimes save_media is invoked with nil uri, in which case the script terminates. Added condition to handle this gracefully.