<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, **kwargs):
 """ Upload a file to the Gett service. Takes keyword arguments. Input: * ``filename`` the filename to use in the Gett service (required) * ``data`` the file contents to store in the Gett service (required) - must be a string * ``sharename`` the name of the share in which to store the data (optional); if not given, a new share will be created. * ``title`` the share title to use if a new share is created (optional) Output: * A :py:mod:`pygett.files.GettFile` object Example:: file = client.upload_file(filaname="foo", data=open("foo.txt").read()) """

        params = None
        if 'filename' not in kwargs:
            raise AttributeError("Parameter 'filename' must be given")
        else:
            params = {
                "filename": kwargs['filename']
            }

        if 'data' not in kwargs:
            raise AttributeError("Parameter 'data' must be given")

        sharename = None
        if 'sharename' not in kwargs:
            share = None
            if 'title' in kwargs:
                share = self.create_share(title=kwargs['title'])
            else:
                share = self.create_share()
            sharename = share.sharename
        else:
            sharename = kwargs['sharename']

        response = GettRequest().post("/files/%s/create?accesstoken=%s" % (sharename, self.user.access_token()), params)

        f = None
        if response.http_status == 200:
            if 'sharename' not in response.response:
                response.response['sharename'] = sharename
            f = GettFile(self.user, **response.response)
            if f.send_data(data=kwargs['data']):
                return f