stack.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:TransIP-STACK-API 作者: Paradoxis 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号