from django.core.files.storage import FileSystemStorage
import os
# from admin_panel.common_functions import *
import random,string

def randomStringFunctionForImage():
	import random,string
	str1 = ''.join((random.choice(string.ascii_letters) for x in range(8)))
	str1 += ''.join((random.choice(string.digits) for x in range(4)))
	sam_list = list(str1)
	random.shuffle(sam_list)
	finalString = ''.join(sam_list)
	return finalString

def uploadTheProfile(image):

	fullPath='media/usermedia'
	fs = FileSystemStorage(location=fullPath)
	fullPath2='/media/usermedia'
	filetype = os.path.splitext(image.name)[1]
	theName=randomStringFunctionForImage()
	theImageName=str(theName)+str(filetype)
	filename = fs.save(theImageName, image)
	return str(fullPath2)+'/'+filename