I’m pretty sure that attachments with duplicate filenames used to behave like this:
- When trying to rename an attachment through the Confluence UI to a filename that is already taken by another attachment, an error was shown.
- When uploading a file through the Confluence UI or the REST API and another attachment with the same filename already existed, a new attachment with a new content ID was created and one ended up with duplicate filenames.
- Because
<ri:attachment>
links reference attachments by filename, such references would randomly point to one of the two files. It was for example not possible to include two images with the same filename on a page. Instead, one of them would be shown twice. - Because the attachments had different IDs, it was possible to rename one of them using the Confluence UI or REST API, without any impact on the other attachment. This would solve the duplicate filename issue.
- Because
The behaviour that I am seeing now:
- When trying to rename an attachment through the Confluence UI to a filename that is already taken by another attachment, an error is still shown.
- When uploading a file through the Confluence UI or the REST API and another attachment with the same filename already exists, that attachment is replaced with the new one. The attachment ID doesn’t change, but a new version of it is created. The old version(s) can still be accessed through the Confluence UI or
/rest/api/content/${attachmentId}/version
, the file can be downloaded through/download/attachments/${attachmentId}/${filename}?version=${version}
(the attachment ID without theatt
prefix in this case).
I am wondering when this was changed and whether it was announced anywhere and I missed it.
It is breaking a feature in our app where we copy the attachments of multiple pages onto a single page. Until now, we have been using the Copy Single Page API with copyAttachments
and an existing_page
destination to copy all the attachments. That call was creating duplicate attachments in case of a filename conflict, which we would resolve after the copy operation by renaming those attachments. Now we will have to change that logic, probably we will have to rename attachments before the operation, as afterwards we have no way to restore the overwritten versions of attachments into new files.