def download_into(self, file: str, buffer: Union[BufferedIOBase, BytesIO]=None, remote_path: str=None) -> IOBase:
"""
Download a file from your STACK account
:param file: File name to download
:param remote_path: Path to find the file in
:param buffer: Buffer to download into (BytesIO, StringIO, file pointer)
:return: BytesIO buffer
"""
if not remote_path:
remote_path = self.__cwd
file = join(remote_path, file.lstrip("/"))
if not buffer:
buffer = BytesIO()
if not isinstance(buffer, BufferedIOBase):
raise StackException("Download buffer must be a binary IO type, please use BytesIO or open your file in 'rb' mode.")
try:
self.webdav.download_to(buffer, file.lstrip("/"))
buffer.seek(0)
return buffer
except WebDavException as e:
raise StackException(e)
评论列表
文章目录