user7432468
user7432468

Reputation:

ftplib upload and download get stuck

I'm trying to upload a file to my VPS (hosted by GoDaddy) via Python's ftplib library:

from ftplib import FTP
session = FTP('ftp.wangsibo.xyz','wsb','Wsb.139764')
file = open('source10.png','rb')
session.storbinary('store_source10.png', file)
file.close()
session.quit()

However it gets stuck at line 4 (the file is only a few k's and it's taking minutes). The same thing happens when I'm trying to read using retrbinary.

I've tried using FileZilla and it worked fine. Any suggestions?

Upvotes: 0

Views: 707

Answers (1)

McGrady
McGrady

Reputation: 11487

FTP.storbinary(command, fp[, blocksize, callback, rest])

Store a file in binary transfer mode. command should be an appropriate STOR command: "STOR filename". fp is an open file object which is read until EOF using its read() method in blocks of size blocksize to provide the data to be stored.

store_source10.png is not a command, you can try to use STOR source10.png.

e.g.

from ftplib import FTP
session = FTP('ftp.wangsibo.xyz','wsb','Wsb.139764')

file=open('source10.png','rb')
session.storbinary('STOR source10.png',file)

file.close()
session.quit()

Upvotes: 1

Related Questions