示例#1
0
    def upload_to(self, buff, remote_path):
        # copy-pasted from the webdav lib with the non-needed additional http queries returned

        urn = Urn(remote_path)
        if urn.is_dir():
            raise OptionNotValid(name="remote_path", value=remote_path)

        self.execute_request(action='upload', path=urn.quote(), data=buff)
示例#2
0
    def upload_file(self, remote_path, local_path, progress=None):
        # copy-pasted from the webdav lib with the non-needed additional http queries returned

        if not os.path.exists(local_path):
            raise LocalResourceNotFound(local_path)

        urn = Urn(remote_path)
        if urn.is_dir():
            raise OptionNotValid(name="remote_path", value=remote_path)

        if os.path.isdir(local_path):
            raise OptionNotValid(name="local_path", value=local_path)

        with open(local_path, "rb") as local_file:
            self.execute_request(action='upload',
                                 path=urn.quote(),
                                 data=local_file)