sftp - Using python's pysftp package, I receive an OSError when trying to upload a file -


i using python 3's paramiko package establish sftp connection , upload files.

i able establish connection server following code.

import paramiko  key_file_test = './path_to_key_file/key_file.pub'  download_uat = {     "username": "xxxxxxxx",     "password": "xxxxxxxx" }  uat_ftp_site = 'sftp-test.site.com'  transport = paramiko.transport((uat_sftp_site,22)) transport.connect(username=download_uat['username'], password=download_uat['password']) transport.add_server_key(key) sftp = paramiko.sftpclient.from_transport(transport)  print(sftp.listdir()) ''' ['archiv'] '''  sftp.put('test_sftp_upload_file.txt', remotepath='./') 

however, when run last line above following error output.

--------------------------------------------------------------------------- oserror                                   traceback (most recent call last) <ipython-input-69-bec34aeb9958> in <module>() ----> 1 sftp.put('test_sftp_upload_file.txt', remotepath='./')  c:\programdata\anaconda3\lib\site-packages\paramiko\sftp_client.py in put(self, localpath, remotepath, callback, confirm)     712         file_size = os.stat(localpath).st_size     713         open(localpath, 'rb') fl: --> 714             return self.putfo(fl, remotepath, file_size, callback, confirm)     715      716     def getfo(self, remotepath, fl, callback=none):  c:\programdata\anaconda3\lib\site-packages\paramiko\sftp_client.py in putfo(self, fl, remotepath, file_size, callback, confirm)     668         .. versionadded:: 1.10     669         """ --> 670         self.file(remotepath, 'wb') fr:     671             fr.set_pipelined(true)     672             size = self._transfer_with_callback(  c:\programdata\anaconda3\lib\site-packages\paramiko\sftp_client.py in open(self, filename, mode, bufsize)     336             imode |= sftp_flag_create | sftp_flag_excl     337         attrblock = sftpattributes() --> 338         t, msg = self._request(cmd_open, filename, imode, attrblock)     339         if t != cmd_handle:     340             raise sftperror('expected handle')  c:\programdata\anaconda3\lib\site-packages\paramiko\sftp_client.py in _request(self, t, *arg)     765     def _request(self, t, *arg):     766         num = self._async_request(type(none), t, *arg) --> 767         return self._read_response(num)     768      769     def _async_request(self, fileobj, t, *arg):  c:\programdata\anaconda3\lib\site-packages\paramiko\sftp_client.py in _read_response(self, waitfor)     817                 # synchronous     818                 if t == cmd_status: --> 819                     self._convert_status(msg)     820                 return t, msg     821   c:\programdata\anaconda3\lib\site-packages\paramiko\sftp_client.py in _convert_status(self, msg)     850             raise ioerror(errno.eacces, text)     851         else: --> 852             raise ioerror(text)     853      854     def _adjust_cwd(self, path):  oserror: bad message 

i'm following docs here http://docs.paramiko.org/en/2.2/api/sftp.html structure code paramiko package.

according documentation, should specify full remote file path.

    :param str remotepath: destination path on sftp server. note         filename should included. specifying directory         may result in error. 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -