2

I'm trying to upload a csv file including accents in the file name. Uploading the same file is working fine through Filezilla.

My code is :

session = ftplib.FTP('ftp.myserver.com','mylogin','mypass')
file = open(myfilepath,'rb')
session.storbinary('STOR myfolder//title_à écho âccent.txt', file)
file.close()
session.quit()

I'm getting the following error :

ftplib.error_perm: 501 Invalid character in command

Any fix ?

2 Answers2

1

This error is coming from the FTP server and it is saying that it does not accept file names with non-ASCII characters.

There are FTP servers which do accept non-ASCII characters - try the server speedtest.tele2.net and upload to the directory upload.

ErikR
  • 51,541
  • 9
  • 73
  • 124
  • Thanks but not sure it's coming from this as Filezilla allows me to upload the file very well. –  Oct 16 '15 at 12:58
0

Specify session.encoding= 'utf-8' as ftplib default encoding seems to be latin-1.