ftplib storbinary
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
There's a problem with SSL and the storbinary method. I get this error:
Error uploading yourfile.mp3: [SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:2685)
A YouTuber posted a fix which creates your own storbinary function and eliminates some code in the original that solves the problem. I attached the fix below. You use this function in place of the method that comes with the library.
def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
self.voidcmd('TYPE I')
with self.transfercmd(cmd, rest) as conn:
while 1:
buf = fp.read(blocksize)
if not buf: break
conn.sendall(buf)
if callback: callback(buf)
return self.voidresp()
----
ftps = FTP_TLS()
ftps.set_pasv(True)
....
for upload in uploads:
print(upload)
with open(upload, 'rb') as file: # Use 'with' to ensure the file is closed properly
remote_filename = os.path.basename(upload) # Get the base filename for uploading
try:
storbinary(ftps, f'STOR {remote_filename}', file)
# ftps.storbinary(f'STOR {remote_filename}', file)
print(f'Successfully uploaded: {remote_filename}')
except all_errors as e:
print(f'Error uploading {remote_filename}: {e}')
# Connect to the server
ftps.connect(ftps_host)
ftps.login(user=ftps_user, passwd=ftps_password)
ftps.prot_p() # Switch to secure data connection
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Parti da ftplib.FTP_TLS.storbinary e riproduci il fallimento del caricamento SSL descritto per Python 3.12 su macOS, confrontandolo con la funzione sostitutiva allegata. Non è indicato alcun file del repository né alcun test; il lavoro è completato quando il caricamento segnalato funziona senza sostituire storbinary e il comportamento dispone di una copertura di regressione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100