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)))
评论列表
文章目录