from django.core.files.storage import FileSystemStorage
import os
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 uploadTheImages(image):
    fullPath='media/admin'
    fs = FileSystemStorage(location=fullPath)
    fullPath2='media/admin'
    filetype = os.path.splitext(image.name)[1]
    theName=randomStringFunctionForImage()
    theImageName=str(theName)+str(filetype)
    filename = fs.save(theImageName, image)
    return str(fullPath2)+'/'+filename


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

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


def randomStringFunctionForPw():
	str1 = ''.join((random.choice(string.ascii_letters) for x in range(10)))
	str1 += ''.join((random.choice(string.digits) for x in range(6)))
	sam_list = list(str1)
	random.shuffle(sam_list)
	finalString = ''.join(sam_list)
	return finalString