Link to a specific attachment version
Asked by Alex Stoeckli:

Hi,

Confluence saves the page with a reference to an attachment, but no version:

```
<ac:link>	<ri:attachment ri:filename="Attachment.pdf">		<ri:page ri:content-title="Other Page"/>	</ri:attachment>	<ac:plain-text-link-body><![CDATA[Stuff]]></ac:plain-text-link-body></ac:link>
```

So this would always point to the most current version of the attachment.

I would like to point to a specific version (e.g. v2, even though there is a v5). Is there a solution for this?

Thank you in advance.


Answers:
author: Diego
body: Hello there!

First thing I would like to address is that in Confluence, we have two types of links:
> * Soft Links
> * Hard Links

Soft links are the links we insert using Confluence way of linking, the linking tool. Those links are automatically updated on Base URL change. This type of link works only for internal stuff.

Hard Links are links we refer using the URL address itself. Those links are what we are used to have all over the internet. We need to manually update them if something happen to the original address.

As you have noted Alex, the soft links do not refer to a specific version. They look straight into the latest.

To refer to a specific attachment version straight into a link, we could proceed like this:
> 1. Go to the page in which the attachment is present
> 2. Preview the attachment
> 3. Open the download link in another tab
>    1. It should look like this:
>       1. http://youraddress:8090/download/attachments/983041/MyAttachment.png?version=3\&modificationDate=1553524676608\&api=v2\&download=true
> 4. Copy that link
> 5. Change the version= parameter to the desired version
> 6. Link that to your desired page

**Notes:**

* This is a hard link, deleting the attachment version will cause a 404
* You will need to update the link manually if needed
* You can change download=true to preview=true so the download is not immediately triggered when a user clicks the link

Now, we can achieve something more polished if we use the Attachments Macro. However, this will show all attachment versions. What we need to check is that **Include old attachment versions**is checked before publishing the page.

Now, can I ask you something else? What is the objective of this link to an older version of an attachment in Confluence?

Maybe we can help you to create a more clean way of doing what you need to achieve!

Looking forward to your reply Alex!

Edit: if you need to look a little deeper into the Storage Format, you can take a look here:

**[Confluence Storage Format](https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html)**

comments: author: Alex Stoeckli
body: Hi Diego,

Thank you for your detailed answer.

It's good to hear that there is a solution. Unfortunately, I don't think we can use this solution on a day to day basis for our users.

**Background information**

We work in a regulated environment where we follow FDA 21 CFR Part 11. According to the regulatory text, electronic records (in our case this would be an Confluence page) shall not be changed once they have been approved.

Now if we take as an example a page called "User Requirements Specification" v11 which includes a picture v1 and approve it with an Atlassian third-party add-on, this would make the page approved. If we then update the page "User Requirements Specification" to v12 and include picture v2, in the page history the page v11 would also point to picture v2. This would violate the integrity of the electronic record.

In the end the requirement would be that each page version points to specific attachment version. The only workaround at the moment is to change the filename each time, so there's only one version of each attachment.

Or is there another solution to this?


author: grant_frisken
body: Did you find a solution to this? It seems like a fairly fundamental issue even outside of medical regulatory requirements - because if you have a page with some images the page history no longer allows you to see what the page looked like at some previous point in time.


author: Sean C
body: We decided to restrict the upload of the same filename by a written procedure. The next step would be to disable or automatically rename uploads of files using an already uploaded filename with a custom add-on.

Not a really an ideal solution, but better than compromising data integrity.


author: Ilona Knapp-Krubally
body: Hi Alex,  

what kind of app / plugin do you use to approve the confluence pages? There are some solutions which always shows the correct attachment version for the approved page version. If attachment version will be changed, then approved status will be changed automatically, too. Or you can design your approval workflow that in the final status adding attachments will not be possible...  

e.g. Comala Document Management (with FDA 21Part11 Compliance Checklist)


Tags: confluence-server

server