Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bambulabs_api/ftp_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ftplib
from io import BytesIO
import ssl

import logging
Expand Down Expand Up @@ -87,6 +88,16 @@ def upload_file(self, file: BinaryIO, file_path: str) -> str:
return self.ftps.storbinary(f'STOR {file_path}', file, blocksize=32768,
callback=lambda x: logging.debug(f"Uploaded {x} bytes")) # noqa # pylint: disable=logging-fstring-interpolation

@connect_and_run
def list_directory(self):
return self.ftps.retrlines('LIST')

@connect_and_run
def download_file(self, file_path: str):
b = BytesIO()
self.ftps.retrbinary(f'RETR {file_path}', b.write)
return b

@connect_and_run
def delete_file(self, file_path: str) -> str:
logging.info(f"Deleting file: {file_path}") # noqa # pylint: disable=logging-fstring-interpolation
Expand Down