def upload(self, localfile: str, remotefile: str, overwrite: bool = True, permission: str = '<STR_LIT>', **kwargs):
valid = self._sb.file_info(remotefile, quiet = True)<EOL>if valid is None:<EOL><INDENT>remf = remotefile<EOL><DEDENT>else:<EOL><INDENT>if valid == {}:<EOL><INDENT>remf = remotefile + self._sb.hostsep + localfile.rpartition(os.sep)[<NUM_LIT:2>]<EOL><DEDENT>else:<EOL><INDENT>remf = remotefile<EOL>if overwrite == False:<EOL><INDENT>return {'<STR_LIT>' : False, <EOL>'<STR_LIT>'     : "<STR_LIT>"+str(remotefile)+"<STR_LIT>"}<EOL><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>fd = open(localfile, '<STR_LIT:rb>')<EOL><DEDENT>except OSError as e:<EOL><INDENT>return {'<STR_LIT>' : False, <EOL>'<STR_LIT>'     : "<STR_LIT>"+str(localfile)+"<STR_LIT>"+str(e)}<EOL><DEDENT>port =  kwargs.get('<STR_LIT:port>', <NUM_LIT:0>)<EOL>if self.sascfg.ssh and self.sascfg.rtunnel and port == <NUM_LIT:0>:<EOL><INDENT>port = self.sascfg.rtunnel<EOL>host = '<STR_LIT:localhost>'<EOL><DEDENT>else:<EOL><INDENT>return self._upload_client(localfile, remotefile, overwrite, permission, **kwargs)<EOL><DEDENT>code = """<STR_LIT>"""+remf+"""<STR_LIT>"""+permission+"""<STR_LIT>"""+str(port)+"""<STR_LIT>"""<EOL>self._asubmit(code, "<STR_LIT:text>")<EOL>sock = socks.socket()<EOL>sock.connect((host, port))<EOL>done = False<EOL>while not done:<EOL><INDENT>try:<EOL><INDENT>while True:<EOL><INDENT>buf  = fd.read1(<NUM_LIT>)<EOL>sent = <NUM_LIT:0><EOL>send = len(buf)<EOL>blen = send<EOL>if blen:<EOL><INDENT>while send:<EOL><INDENT>try:<EOL><INDENT>sent = <NUM_LIT:0><EOL>sent = sock.send(buf[blen-send:blen])<EOL><DEDENT>except (BlockingIOError):<EOL><INDENT>pass<EOL><DEDENT>except (OSError):<EOL><INDENT>sock.close()<EOL>fd.close()<EOL>sock = socks.socket()<EOL>sock.connect((host, port))<EOL>fd = open(localfile, '<STR_LIT:rb>')<EOL>sleep(<NUM_LIT>)<EOL>break<EOL><DEDENT>send -= sent<EOL><DEDENT><DEDENT>else:<EOL><INDENT>done = True<EOL>sock.shutdown(socks.SHUT_RDWR)<EOL>sock.close()<EOL>fd.close()<EOL>break<EOL><DEDENT><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>sock.close()<EOL>fd.close()<EOL>ll = self.submit("<STR_LIT>", '<STR_LIT:text>')<EOL>return {'<STR_LIT>' : False, <EOL>'<STR_LIT>'     : "<STR_LIT>"+ll['<STR_LIT>']}<EOL><DEDENT><DEDENT>ll = self.submit("<STR_LIT>", '<STR_LIT:text>')<EOL>return {'<STR_LIT>' : True, <EOL>'<STR_LIT>'     : ll['<STR_LIT>']}<EOL>
This method uploads a local file to the SAS servers file system.
localfile  - path to the local file to upload 
remotefile - path to remote file to create or overwrite
overwrite  - overwrite the output file if it exists?
permission - permissions to set on the new file. See SAS Filename Statement Doc for syntax