In the controller action
image_file = change_img_params(params[:avatar]) #params[:avatar] - base64 string
def change_img_params(img)
begin
Base64.decode64(img) #To check if thats a base64 string
if img
img = file_decode(img.split(',')[1],"some file name") #getting only the string leaving out the data/<format>
end