<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def upload(self, path, engine, description=None):
 """Create a new config resource in the slicing service and upload the path contents to it"""


        if description is None:
            head, tail = ntpath.split(path)
            description = tail or ntpath.basename(head)

        url = "http://quickslice.{}/config/raw/".format(self.config.host)

        with open(path) as config_file:
            content = config_file.read()

        payload = {"engine": engine,
                   "description": description,
                   "content": content}

        post_resp = requests.post(url, json=payload, cookies={"session": self.session})
        if not post_resp.ok:
            raise errors.ResourceError("config upload to slicing service failed")

        self.description = description

        self.location = post_resp.headers["Location"]