import os
import random
import string
from django.core.files.storage import FileSystemStorage

def randomStringFunctionForImage():
    str1 = ''.join((random.choice(string.ascii_letter) 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 uploadTheDocument(image):
	fullPath='media/aiagent_document'
	fs = FileSystemStorage(location=fullPath)
	fullPath2='/media/aiagent_document'
	filetype = os.path.splitext(image.name)[1]
	theName=randomStringFunctionForImage()
	theImageName=str(theName)+str(filetype)
	filename = fs.save(theImageName, image)
	return str(fullPath2)+'/'+filename
