ftplib storbinary
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Parte de ftplib.FTP_TLS.storbinary y reproduce el fallo de carga SSL descrito para Python 3.12 en macOS, comparándolo con la función de reemplazo adjunta. No se nombra ningún archivo del repositorio ni ninguna prueba; se considera terminado cuando la carga indicada funciona sin reemplazar storbinary y el comportamiento tiene cobertura de regresión.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- networking
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100