FranGoitia
FranGoitia

Reputation: 1993

error_perm: 500 Unknown command Python ftplib storbinary

I'm trying to upload a file using ftplib in Python.

ftp = FTP('...')
ftp.login('user', 'pass')                   
f = open(filename)
ftp.storbinary(filename, f)
f.close()
ftp.quit()

storbinary is returning error_perm: 500 Unknown command., which is strange since I'm following its specification. Google search returns very little information. Anyone encountered this problem ?

Upvotes: 5

Views: 7739

Answers (1)

Tom
Tom

Reputation: 22841

It looks like you're using storbinary incorrectly. You want to pass "STOR filename-at-location", f) to send the file. Does this work?

ftp = FTP('...')
ftp.login('user', 'pass')
with open(filename) as contents:
    ftp.storbinary('STOR %s' % filename, contents)
ftp.quit()

Upvotes: 8

Related Questions