Skip to content

Confluence page attachment upload (binary/multipart) — extend jr wiki with attachment upload #669

Description

@SackOfHacks

Motivation

Publishing PDFs (e.g. generated report one-pagers) to a Confluence page needs the file uploaded as a page attachment. There is currently no jr path to attach a binary file to a Confluence page:

  • jr api -d @file reads the file with std::fs::read_to_string (src/cli/api.rs:107) — UTF-8 only. A PDF's bytes are not valid UTF-8, so jr api cannot even read a binary body, let alone send multipart/form-data (it fails with stream did not contain valid UTF-8).
  • The native multipart uploader added for Jira attachments (jr issue attachment upload, src/cli/issue/attachments.rs) is hard-wired to the Jira /rest/api/3/issue/{key}/attachments endpoint — it isn't reachable for the Confluence /wiki/.../child/attachment endpoint.

The net effect is that a workflow that is otherwise fully jr-native (create/update the page body via jr api PUT) has to fall back to a link-only page and host the binary elsewhere, because the one binary-upload step has no jr path.

Current workaround

Build the page as a link index (each row links out to wherever the PDF is already hosted) via a jr api PUT of the page body. The binary is never attached to the Confluence page.

Proposed feature

Extend the jr wiki tree (#581) with a Confluence attachment upload:

jr wiki attachment upload <PAGE_ID> <FILE>...

A multipart/form-data POST to /wiki/rest/api/content/{id}/child/attachment (v1) or the v2 equivalent, with header X-Atlassian-Token: nocheck, reusing the existing Jira-attachment multipart machinery generalized off the Jira-issue endpoint.

Optionally, also give jr api two lower-level primitives that would unblock arbitrary binary Atlassian uploads generically:

  • --data-binary @file — send raw bytes with no UTF-8 decode (fixes the read_to_string limitation above).
  • --form field=@file — a multipart/form-data mode.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions