Accessing page attachments from the client side of a macro


I’m writing a macro plugin that wants to work with page attachments on the client side. I’ve already set up an atlas-connect environment, but I stuck with this problem.

What I’ve done so far:

  • Using an attachment parameter I get the name of an attachment.
  • Using the /rest/api/content/<pageId>/child/attachment call I get the download url for the attachment. These are looking someting like this: /download/attachments/12345/filename.png?....
  • I can download attachment on the server side by sending a requests with the url above.

The problem is that it doesn’t work on the client side (the view for the macro). If I try to download attachment with full url (like I get a CORS error that doesn’t allow me to download the file.

I can workaround it by downloading the file on the server side, and then serving the downloaded content to the client side, but in this case I have to download everything twice.

Do you have any idea how to solve this?

Dear @kovacsv ,

downloading text based files via AP.request shouldn’t be a problem. From earlier experiences I know that downloading binary files however was tricky or impossible. I think this Jira ticket might apply for Confluence as well.

In one of our apps we download binary files going through the server as you indicated.

I hope that helps


Thanks a lot, @andreas1, I’ll take a look. Unfortunately I have to deal with binary files, too. :frowning:

Hi @kovacsv,
Such endpoint will be provided as part of the Atlassian Developer Status - Attachments download using OAuth in Confluence.

It should be available soon and an announcement will be posted on the community once it is available.


Great news, thanks @ccurti!