def _upload_file(self, authdata, attachment, reg_key):
upload_dict = authdata[<EOL>"<STR_LIT>"<EOL>]  <EOL>upload_list = [("<STR_LIT:key>", upload_dict["<STR_LIT:key>"])]<EOL>for k in upload_dict:<EOL><INDENT>if k != "<STR_LIT:key>":<EOL><INDENT>upload_list.append((k, upload_dict[k]))<EOL><DEDENT><DEDENT>upload_list.append(("<STR_LIT:file>", open(attachment, "<STR_LIT:rb>").read()))<EOL>upload_pairs = tuple(upload_list)<EOL>try:<EOL><INDENT>upload = requests.post(<EOL>url=authdata["<STR_LIT:url>"],<EOL>files=upload_pairs,<EOL>headers={<EOL>"<STR_LIT>": "<STR_LIT>"<EOL>% __version__<EOL>},<EOL>)<EOL><DEDENT>except (requests.exceptions.ConnectionError):<EOL><INDENT>raise ze.UploadError("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>upload.raise_for_status()<EOL><DEDENT>except requests.exceptions.HTTPError:<EOL><INDENT>error_handler(upload)<EOL><DEDENT>return self._register_upload(authdata, reg_key)<EOL>
Step 2: auth successful, and file not on server
zotero.org/support/dev/server_api/file_upload#a_full_upload

reg_key isn't used, but we need to pass it through to Step 3