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 https://username.atlassian.net/wiki/download/attachments/12345/filename.png) 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.
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’ve seen the post about the new API endpoint (New Download attachment REST API endpoint), but I don’t think it will solve the problem, because it still won’t work for binary files accessing through AP.request.
Do you think this issue will be solved? Now it prevents me from releasing my app.
Hi @LucasPan, unfortunately the proposed workaround doesn’t work, because the requests will be blocked by CORS policy. Also, serving everything through the app server is not an option, because it would cause unnecessary server traffic, and unnecessary extra waiting time for users.
Hi @kovacsv - did you end up resolving this issue? We are encountering exactly the same problem with a Spring Boot Atlassian Connect App. The app needs to load a ZIP file attached to a page, uncompress the contents and render. Whilst this all works fine on the server side, ideally it would be performed client side when the dynamic macro renders,