from ticket.helper import send_image_to_server


def upload_image(req=None, field=None):
    if req.data[field] != "":
        req.data[field] = send_image_to_server(req.data[field])
    elif req.data[field] == "":
        req.data[field] = "empty"
    return req


def upload_listed_image(req=None, field=None):
    image_list = []
    if req.data[field] != []:
        for item in req.data[field]:
            image_list.append(send_image_to_server(item))
        req.data.pop(field)
        req.data[field] = image_list
    elif req.data[field] == "":
        req.data[field] = "empty"
    return req
