Search code examples
pythonftptwisted

Cannot write to Twisted FTP server


I am currently using the one-line Twisted FTP server to transfer files back and forth between machines:

twistd -n ftp

Which works fine for downloading files from the server. However when I try to write to the server using:

with open('testFile.bmp', 'rb') as f:
    ftp.storbinary('STOR ' + 'testFile.bmp', f)
with open('surrogate.py', 'rb') as f:
    ftp.storbinary('STOR ' + 'surrogateCode.py', f)

I get errors:

Traceback (most recent call last):
  File "client.py", line 13, in <module>
    ftp.storbinary('STOR ' + 'testFile.bmp', f)
  File "/usr/lib/python2.7/ftplib.py", line 461, in storbinary
    conn = self.transfercmd(cmd, rest)
  File "/usr/lib/python2.7/ftplib.py", line 368, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/usr/lib/python2.7/ftplib.py", line 331, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "/usr/lib/python2.7/ftplib.py", line 244, in sendcmd
    return self.getresp()
  File "/usr/lib/python2.7/ftplib.py", line 219, in getresp
    raise error_perm, resp
ftplib.error_perm: 550 Requested action not taken: internal server error

I tried it with the WinSCP FTP client and receive this error:

Copying files to remote side failed.
Requested action not taken: internal server error

I'm not sure if I am writing incorrectly or calling the server incorrectly.


Solution

  • Your code looks okay and from your description of the problem (encountering it in both WinSCP and the twisted library) I would hazard a guess that the issue is on the server side.

    Using http://en.wikipedia.org/wiki/List_of_FTP_server_return_codes as a reference

    Error 550 and the error ftplib.error_perm would suggest that perhaps the user you au don't have write permissions to that location