Code for image and video saving into local memory.