Upload & download wav file to X server (X-Server) by FTP with Python

Upload completed version

import ftplib
def ftp_upload(filename):
  ftp = ftplib.FTP('**.**.xdomain.ne.jp')#Put the FTP host in **
  ftp.set_pasv('true')
  ftp.login('**.**.xdomain.jp','Please enter your password')#Please enter your account name in **
  ftp.cwd('/')
  f = open(filename,'rb')
  ftp.storbinary('STOR /' + filename, f)
  f.close()

ftp_upload('a.wav')

I got this error until I got to the finished version ...

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 6-17: ordinal not in range(256)

Code with the error

import ftplib
def ftp_upload(filename):
  ftp = ftplib.FTP('**.**.xdomain.ne.jp')#Put the FTP host in **
  ftp.set_pasv('true')
  ftp.login('**.**.xdomain.jp','zvjv8pc8')#Please enter your account name in **
  ftp.cwd('/')
  f = open(filename,'rb')
  ftp.storbinary('STOR /' + filename, f)
  f.close()

ftp_upload('Ah.wav')

solution

Do not put Japanese in the file name

Download completed version

import ftplib
filename = "a.wav"#A on the server.wav file
ftp = ftplib.FTP('**.**.xdomain.ne.jp')
ftp.login('**.**.xdomain.jp','Please enter your password')
ftp.cwd('/')
ftp.retrbinary("RETR " + "a.wav" ,open("local.wav", "wb").write)#A on the server.wav file local.Save as wav
ftp.quit()

Recommended Posts

Upload & download wav file to X server (X-Server) by FTP with Python
Upload text file to rental server by ftp
[Python] I will upload the FTP to the FTP server.
Download csv file with python
[Python] Write to csv file with Python
Implemented file download with Python + Bottle
Output to csv file with Python
MP3 to WAV conversion with Python
How to use FTP with Python
File upload to Azure Storage (Python)
Image upload & download to Azure Storage. With Python + requests + REST API
Upload file to GCP's Cloud Storage (GCS) ~ Load with local Python
Read CSV file with python (Download & parse CSV file)
Upload images to Google Drive with Python
I tried to communicate with a remote server by Socket communication with Python.
Download the file by specifying the download destination with Python & Selemiun & Chrome (Windows version)
How to upload with Heroku, Flask, Python, Git (4)
How to read a CSV file with Python 2/3
ODBC connection to FileMaker 11 Server Advanced with Python 3
[Python] How to read excel file with pandas
Convert svg file to png / ico with Python
High resolution acoustic signal processing (1) --How to read 24-bit wav file with Python
Upload files to Google Drive with Lambda (Python)
Wav file generation from numeric text with python
Read line by line from a file with Python
I want to write to a file with Python
Download the file while viewing the progress in Python 3.x
I tried to touch the CSV file with Python
How to upload with Heroku, Flask, Python, Git (Part 3)
[Python] How to specify the download location with youtube-dl
How to measure mp3 file playback time with python
Read the xml file by referring to the Python tutorial
How to convert JSON file to CSV file with Python Pandas
How to upload with Heroku, Flask, Python, Git (Part 1)
How to upload with Heroku, Flask, Python, Git (Part 2)
ODBC access to SQL Server from Linux with Python
File upload with django
Local server with python
screen and split screen with python and ssh login to remote server
How to switch the configuration file to be read by Python
How to upload files to Cloud Storage with Firebase's python SDK
[Python Kivy] How to create an exe file with pyinstaller
How to read an Excel file (.xlsx) with Pandas [Python]
I tried to divide the file into folders with Python
Try to decipher the garbled attachment file name with Python
How to upload a file to Cloud Storage using Python [Make a fixed point camera with Raspberry PI # 1]
Process the gzip file UNLOADed with Redshift with Python of Lambda, gzip it again and upload it to S3
Connect to BigQuery with Python
x86 compiler self-made with python
Download the file in Python
Draw netCDF file with python
Connect to Wikipedia with Python
Post to slack with Python 3
Upload a file to Dropbox
Switch python to 2.7 with alternatives
Write to csv with Python
Easy HTTP server with Python
File upload with Flask + jQuery
Convert python 3.x code to python 2.x
[Python] Convert CSV file uploaded to S3 to JSON file with AWS Lambda
[Python] A memo to operate ROM created by GBDK with PyBoy