Beispiel #1
0
    def _put_new_text_file(
        self,
        provider,
        environ,
        file_path,
        file_content,
    ):
        # This part id a reproduction of
        # wsgidav.request_server.RequestServer#doPUT

        # Grab parent folder where create file
        parentRes = provider.getResourceInst(
            util.getUriParent(file_path),
            environ,
        )
        assert parentRes, 'we should found folder for {0}'.format(file_path)

        new_resource = parentRes.createEmptyResource(
            util.getUriName(file_path), )
        write_object = new_resource.beginWrite(
            contentType='application/octet-stream', )
        write_object.write(file_content)
        write_object.close()
        new_resource.endWrite(withErrors=False)

        # Now file should exist
        return provider.getResourceInst(
            file_path,
            environ,
        )
Beispiel #2
0
    def _put_new_text_file(
            self,
            provider,
            environ,
            file_path,
            file_content,
    ):
        # This part id a reproduction of
        # wsgidav.request_server.RequestServer#doPUT

        # Grab parent folder where create file
        parentRes = provider.getResourceInst(
            util.getUriParent(file_path),
            environ,
        )
        ok_(parentRes, msg='we should found folder for {0}'.format(file_path))

        new_resource = parentRes.createEmptyResource(
            util.getUriName(file_path),
        )
        write_object = new_resource.beginWrite(
            contentType='application/octet-stream',
        )
        write_object.write(file_content)
        write_object.close()
        new_resource.endWrite(withErrors=False)

        # Now file should exist
        return provider.getResourceInst(
            file_path,
            environ,
        )
Beispiel #3
0
def webdav_put_new_test_file_helper(
    provider: TracimDavProvider,
    environ: typing.Dict[str, typing.Any],
    file_path: str,
    file_content: bytes,
) -> _DAVResource:
    # This part id a reproduction of
    # wsgidav.request_server.RequestServer#doPUT

    # INFO - G.M - 2019-07-11 - set content_length to correct value according to file_content
    environ["CONTENT_LENGTH"] = len(file_content)

    # Grab parent folder where create file
    parentRes = provider.getResourceInst(wsgidav_util.getUriParent(file_path),
                                         environ)
    assert parentRes, "we should found folder for {0}".format(file_path)

    new_resource = parentRes.createEmptyResource(
        wsgidav_util.getUriName(file_path))
    write_object = new_resource.beginWrite(
        contentType="application/octet-stream")
    write_object.write(file_content)
    write_object.close()
    new_resource.endWrite(withErrors=False)

    # Now file should exist
    return provider.getResourceInst(file_path, environ)
	def filename(self):
		return util.getUriName(self.path)