Skip to content

Add hydration support for Content::CONTENT_TYPE_ATTACHMENT #18

Description

@virtualLast

The content API exposes attachment children through:

$contentApi->children(
    $page,
    Content::CONTENT_TYPE_ATTACHMENT,
);

This calls the expected Confluence REST endpoint:

GET /content/{pageId}/child/attachment

However, attachment results cannot currently be hydrated.

The response is passed through ContentSearchResult::load(), which delegates each result to AbstractContent::load(). That method only maps the page and comment content types, so attachment results throw:

HydrationException: Invalid content type: attachment

The library already defines:

Content::CONTENT_TYPE_ATTACHMENT

so this appears to be incomplete attachment support rather than an unsupported endpoint.

My proposed scope would be:

  • add a ContentAttachment entity extending AbstractContent
  • map Content::CONTENT_TYPE_ATTACHMENT in AbstractContent::load()
  • hydrate common content fields
  • hydrate stable attachment-specific fields where available, such as media type, file size and download link
  • add tests covering direct attachment hydration and attachments returned through ContentSearchResult

I would keep attachment uploading, replacement and binary downloading outside the scope of the initial change.

Happy to discuss and amend as you see fit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions