<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, filename=None, json=None, as_type='zip'):
 """ Upload an IPList to the SMC. The contents of the upload are not incremental to what is in the existing IPList. So if the intent is to add new entries, you should first retrieve the existing and append to the content, then upload. The only upload type that can be done without loading a file as the source is as_type='json'. :param str filename: required for zip/txt uploads :param str json: required for json uploads :param str as_type: type of format to upload in: txt|json|zip (default) :raises IOError: filename specified cannot be loaded :raises CreateElementFailed: element creation failed with reason :return: None """

        headers = {'content-type': 'multipart/form-data'}
        params = None
        files = None
        if filename:
            files = {'ip_addresses': open(filename, 'rb')}
        if as_type == 'json':
            headers = {'accept': 'application/json',
                       'content-type': 'application/json'}
        elif as_type == 'txt':
            params = {'format': 'txt'}

        self.make_request(
            CreateElementFailed,
            method='create',
            resource='ip_address_list',
            headers=headers, files=files, json=json,
            params=params)