Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Why can't I UPDATE an attachment with the Confluence Java API?

Brian Alston May 28, 2015

If I use the default Confluence GUI to add an updated version of an existing page attachment, the attachment is updated, and Confluence keeps a version history of the attachment. If our users use the ConfluenceSoapService to add an updated version of an existing page attachment, the attachment is updated, and Confluence keeps a version history of the attachment.

 

However ... if I attempt to add an updated version of an existing page attachment with the AttachmentManager, the attachment does not get updated; Confluence creates a brand new attachment entry on the page.

 

What gives? Can I not update an attachment using the Java API? Can I only do this if I call the ConfluenceSoapService locally? This should not be this difficult, and it is driving me crazy.

 

Please Help

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Dennis Andersen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2016

Hi Brian & Laura,

I was having the same issue but recently found a solution. My solution is based on the fact that I already have an Attachment object to work with. It's possible to re-write if you only have a file/inputstream as well. 

It depends on InputStreamAttachmentResource.java and FileUploadManager.java along with the attachmentManager.

 

import com.atlassian.confluence.pages.FileUploadManager;

Attachment a = ...; // Get your attachmentObject or File/Inputstream
Page spaceHomePage = ...; // ContentEntityObject where we save the attachment.

AttachmentResource attachmentResource = new InputStreamAttachmentResource(attachmentManager.getAttachmentData(a), a.getFileName(), a.getContentType(), a.getFileSize());

fileUploadManager.storeResource(attachmentResource, spaceHomePage);

 

 

0 votes
Brian Alston May 23, 2016

I'm sorry, but I was never able to figure this out. In fact, I disliked working with Confluence so much that I found a different job (Android developer now). Good luck, I hope you find your answer.

0 votes
Laura Martin May 23, 2016

Hi,

I know this was a year ago, but did you find a solution to this? I am also in the same position and it is driving me mad.

Thanks in advance,

Laura

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events