Hierarchy

  • CommonHttpService
    • ContentAttachmentsService

Constructors

  • Internal

    Create a new instance of the service.

    Parameters

    • getClientInstance: (() => CommonHttpClient)
        • (): CommonHttpClient
        • Returns CommonHttpClient

    Returns ContentAttachmentsService

Methods

  • Adds an attachment to a piece of content. This method only adds a new attachment. If you want to update an existing attachment, use Create or update attachments.

    Note, you must set a X-Atlassian-Token: nocheck header on the request for this method, otherwise it will be blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.

    The media type 'multipart/form-data' is defined in RFC 7578. Most client libraries have classes that make it easier to implement multipart posts, like the MultipartEntityBuilder Java class provided by Apache HTTP Components.

    Note, according to RFC 7578, in the case where the form data is text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used in that part. In the case of this API endpoint, the comment body parameter should be sent with type=text/plain and charset=utf-8 values. This will force the charset to be UTF-8.

    Example: This curl command attaches a file ('example.txt') to a container (id='123') with a comment and minorEdits=true.

    curl -D- \
    -u admin:admin \
    -X POST \
    -H 'X-Atlassian-Token: nocheck' \
    -F 'file=@"example.txt"' \
    -F 'minorEdit="true"' \
    -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
    https://myhost/wiki/rest/api/content/123/child/attachment

    Permissions required: Permission to update the content.

    Parameters

    • params: {
          id: string;
          requestBody: unknown;
          status?: "current" | "draft";
      }
      • id: string

        The ID of the content to add the attachment to.

      • requestBody: unknown
      • Optionalstatus?: "current" | "draft"

        The status of the content that the attachment is being added to.

    Returns Promise<ContentArray>

    Returned if the attachments were added to the content.

    POST /wiki/rest/api/content/{id}/child/attachment @scopes-current write:confluence-file @scopes-beta read:content-details:confluence, write:attachment:confluence

  • Adds an attachment to a piece of content. If the attachment already exists for the content, then the attachment is updated (i.e. a new version of the attachment is created).

    Note, you must set a X-Atlassian-Token: nocheck header on the request for this method, otherwise it will be blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.

    The media type 'multipart/form-data' is defined in RFC 7578. Most client libraries have classes that make it easier to implement multipart posts, like the MultipartEntityBuilder Java class provided by Apache HTTP Components.

    Note, according to RFC 7578, in the case where the form data is text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used in that part. In the case of this API endpoint, the comment body parameter should be sent with type=text/plain and charset=utf-8 values. This will force the charset to be UTF-8.

    Example: This curl command attaches a file ('example.txt') to a piece of content (id='123') with a comment and minorEdits=true. If the 'example.txt' file already exists, it will update it with a new version of the attachment.

    curl -D- \
    -u admin:admin \
    -X PUT \
    -H 'X-Atlassian-Token: nocheck' \
    -F 'file=@"example.txt"' \
    -F 'minorEdit="true"' \
    -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
    http://myhost/rest/api/content/123/child/attachment

    Permissions required: Permission to update the content.

    Parameters

    • params: {
          id: string;
          requestBody: unknown;
          status?: "current" | "draft";
      }
      • id: string

        The ID of the content to add the attachment to.

      • requestBody: unknown
      • Optionalstatus?: "current" | "draft"

        The status of the content that the attachment is being added to. This should always be set to 'current'.

    Returns Promise<ContentArray>

    Returned if the attachments were added to the content.

    PUT /wiki/rest/api/content/{id}/child/attachment @scopes-current write:confluence-file @scopes-beta read:content-details:confluence, write:attachment:confluence

  • Redirects the client to a URL that serves an attachment's binary data.

    Parameters

    • params: {
          attachmentId: string;
          id: string;
          status?: string[];
          version?: number;
      }
      • attachmentId: string

        The ID of the attachment to download.

      • id: string

        The ID of the content that the attachment is attached to.

      • Optionalstatus?: string[]

        The statuses allowed on the retrieved attachment. If this parameter is absent, it will default to current.

      • Optionalversion?: number

        The version of the attachment. If this parameter is absent, the redirect URI will download the latest version of the attachment.

    Returns Promise<void>

    GET /wiki/rest/api/content/{id}/child/attachment/{attachmentId}/download @scopes-current readonly:content.attachment:confluence @scopes-beta read:attachment:confluence

  • Updates the binary data of an attachment, given the attachment ID, and optionally the comment and the minor edit field.

    This method is essentially the same as Create or update attachments, except that it matches the attachment ID rather than the name.

    Note, you must set a X-Atlassian-Token: nocheck header on the request for this method, otherwise it will be blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.

    The media type 'multipart/form-data' is defined in RFC 7578. Most client libraries have classes that make it easier to implement multipart posts, like the MultipartEntityBuilder Java class provided by Apache HTTP Components.

    Note, according to RFC 7578, in the case where the form data is text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used in that part. In the case of this API endpoint, the comment body parameter should be sent with type=text/plain and charset=utf-8 values. This will force the charset to be UTF-8.

    Example: This curl command updates an attachment (id='att456') that is attached to a piece of content (id='123') with a comment and minorEdits=true.

    curl -D- \
    -u admin:admin \
    -X POST \
    -H 'X-Atlassian-Token: nocheck' \
    -F 'file=@"example.txt"' \
    -F 'minorEdit="true"' \
    -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
    http://myhost/rest/api/content/123/child/attachment/att456/data

    Permissions required: Permission to update the content.

    Parameters

    • params: {
          attachmentId: string;
          id: string;
          requestBody: unknown;
      }
      • attachmentId: string

        The ID of the attachment to update.

      • id: string

        The ID of the content that the attachment is attached to.

      • requestBody: unknown

    Returns Promise<null | Content>

    Returned if the attachment is updated.

    POST /wiki/rest/api/content/{id}/child/attachment/{attachmentId}/data @scopes-current write:confluence-file @scopes-beta read:content-details:confluence, write:attachment:confluence

  • Method to initialize the class. Normally used to set up validation rules.

    Returns void