import os

UPLOAD_DIR = "uploads/tickets/"
MAX_FILE_SIZE_MB=5
async def store_image(files,companyname):
    os.makedirs(UPLOAD_DIR+str(companyname) + "/", exist_ok=True)
    list_of_files = []
    print(files)
    for file in files:
        file_location = os.path.join(UPLOAD_DIR, file.filename)
        try:
            with open(file_location, "wb") as f:
                contents=await file.read()
                if len(contents) > MAX_FILE_SIZE_MB * 1024 * 1024:
                    return {"error": f"{file.filename} is too large"}
                f.write(contents)
                print()
                list_of_files.append(file_location)
        except Exception as e:
            print(e)
    return list_of_files
