Ejemplo n.º 1
0
def save_file(file):
    if file and allowed_file(file.filename):
        random_folder = tools.id_generator()
        filepath = "data/" + random_folder
        os.makedirs(filepath)
        filename = filepath + "/" + secure_filename(file.filename)
        file.save(filename)
    return filename
Ejemplo n.º 2
0
 def _mk_hash():
     hash = None
     while not hash or Handout.objects.filter(hash=hash).count():
         hash = tools.id_generator(size=6)
     return hash
Ejemplo n.º 3
0
 def _mk_hash():
     """Used by PhotoUploader to generate a filename"""
     hash = None
     while not hash or Photo.objects.filter(hash=hash).count():
         hash = tools.id_generator(size=6)
     return hash