stack.py 文件源码

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

项目:TransIP-STACK-API 作者: Paradoxis 项目源码 文件源码
def upload(self, file, name: str=None, path: str=None) -> StackFile:
        """
        Upload a file to Stack
        :param file: IO pointer or string containing a path to a file
        :param name: Custom name which will be used on the remote server, defaults to file.name
        :param path: Path to upload it to, defaults to current working directory
        :return: Instance of a stack file
        """
        if not path:
            path = self.__cwd

        if isinstance(file, IOBase):
            return self.__upload(file=file, path=path, name=name)

        if isinstance(file, str):
            with open(file, "rb") as fd:
                return self.__upload(file=fd, path=path, name=name)

        raise StackException("File should either be a path to a file on disk or an IO type, got: {}".format(type(file)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号