Example #1
0
 def createEmptyResource(self, file_name: str):
     """
     Create a new file on the current workspace/folder.
     """
     content = None
     fixed_file_name = webdav_convert_file_name_to_display(file_name)
     path = os.path.join(self.path, file_name)
     resource = self.provider.getResourceInst(path, self.environ)
     if resource:
         content = resource.content
     try:
         self.content_api.check_upload_size(
             int(self.environ["CONTENT_LENGTH"]), self.workspace)
     except (
             FileSizeOverMaxLimitation,
             FileSizeOverWorkspaceEmptySpace,
             FileSizeOverOwnerEmptySpace,
     ) as exc:
         raise DAVError(HTTP_REQUEST_ENTITY_TOO_LARGE, contextinfo=str(exc))
     # return item
     return FakeFileStream(
         session=self.session,
         file_name=fixed_file_name,
         content_api=self.content_api,
         workspace=self.workspace,
         content=content,
         parent=self.content,
         path=self.path + "/" + fixed_file_name,
     )
Example #2
0
    def createEmptyResource(self, file_name: str):
        """
        [For now] we don't allow to create files right under workspaces.
        Though if we come to allow it, deleting the error's raise will make it possible.
        """
        # TODO : remove commentary here raise DAVError(HTTP_FORBIDDEN)
        if "/.deleted/" in self.path or "/.archived/" in self.path:
            raise DAVError(HTTP_FORBIDDEN)

        content = None

        # Note: To prevent bugs, check here again if resource already exist
        # fixed path
        fixed_file_name = webdav_convert_file_name_to_display(file_name)
        path = os.path.join(self.path, file_name)
        resource = self.provider.getResourceInst(path, self.environ)
        if resource:
            content = resource.content

        # return item
        return FakeFileStream(
            session=self.session,
            file_name=fixed_file_name,
            content_api=self.content_api,
            workspace=self.workspace,
            content=content,
            parent=self.content,
            path=self.path + "/" + fixed_file_name,
        )
Example #3
0
 def beginWrite(self, contentType: str = None) -> FakeFileStream:
     return FakeFileStream(
         content=self.content,
         content_api=self.content_api,
         file_name=self.content.file_name,
         workspace=self.content.workspace,
         path=self.path,
         session=self.session,
     )
Example #4
0
 def beginWrite(self, contentType: str = None) -> FakeFileStream:
     try:
         self.content_api.check_upload_size(
             int(self.environ["CONTENT_LENGTH"]), self.content.workspace)
     except (
             FileSizeOverMaxLimitation,
             FileSizeOverWorkspaceEmptySpace,
             FileSizeOverOwnerEmptySpace,
     ) as exc:
         raise DAVError(HTTP_REQUEST_ENTITY_TOO_LARGE, contextinfo=str(exc))
     return FakeFileStream(
         content=self.content,
         content_api=self.content_api,
         file_name=self.content.file_name,
         workspace=self.content.workspace,
         path=self.path,
         session=self.session,
     )
Example #5
0
    def createEmptyResource(self, file_name: str):
        """
        [For now] we don't allow to create files right under workspaces.
        Though if we come to allow it, deleting the error's raise will make it possible.
        """
        # TODO : remove commentary here raise DAVError(HTTP_FORBIDDEN)
        if "/.deleted/" in self.path or "/.archived/" in self.path:
            raise DAVError(HTTP_FORBIDDEN)

        content = None

        # Note: To prevent bugs, check here again if resource already exist
        # fixed path
        fixed_file_name = webdav_convert_file_name_to_display(file_name)
        path = os.path.join(self.path, file_name)
        resource = self.provider.getResourceInst(path, self.environ)
        if resource:
            content = resource.content
        try:
            self.content_api.check_upload_size(
                int(self.environ["CONTENT_LENGTH"]), self.workspace)
        except (
                FileSizeOverMaxLimitation,
                FileSizeOverWorkspaceEmptySpace,
                FileSizeOverOwnerEmptySpace,
        ) as exc:
            raise DAVError(HTTP_REQUEST_ENTITY_TOO_LARGE, contextinfo=str(exc))
        # return item
        return FakeFileStream(
            session=self.session,
            file_name=fixed_file_name,
            content_api=self.content_api,
            workspace=self.workspace,
            content=content,
            parent=self.content,
            path=self.path + "/" + fixed_file_name,
        )