<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_file(self, path=None, stream=None, name=None, **kwargs):
 """ Uploads file to WeedFS I takes either path or stream and name and upload it to WeedFS server. Returns fid of the uploaded file. :param string path: :param string stream: :param string name: :rtype: string or None """

        params = "&".join(["%s=%s" % (k, v) for k, v in kwargs.items()])
        url = "http://{master_addr}:{master_port}/dir/assign{params}".format(
            master_addr=self.master_addr,
            master_port=self.master_port,
            params="?" + params if params else ''
        )
        data = json.loads(self.conn.get_data(url))
        if data.get("error") is not None:
            return None
        post_url = "http://{url}/{fid}".format(
            url=data['publicUrl' if self.use_public_url else 'url'],
            fid=data['fid']
        )

        if path is not None:
            filename = os.path.basename(path)
            with open(path, "rb") as file_stream:
                res = self.conn.post_file(post_url, filename, file_stream)
        # we have file like object and filename
        elif stream is not None and name is not None:
            res = self.conn.post_file(post_url, name, stream)
        else:
            raise ValueError(
                "If `path` is None then *both* `stream` and `name` must not"
                " be None ")
        response_data = json.loads(res)
        if "size" in response_data:
            return data.get('fid')
        return None