Hi,
I need to batch upload files located on the Confluence server (or some where else in the filesystem if possible) and create attachments within Confluence using a plugin, can anybody give me a hint how to achieve the upload?
Community moderators have prevented the ability to post new answers.
This will send events
//store attachment //pdf is byte array (byte[]) AttachmentResource resource = new InputStreamAttachmentResource(new ByteArrayInputStream(pdf), filenameX, "application/pdf", pdf.length, ""); fileUploadManager.storeResource(resource, page); //attachment is stored. to get info about attachment. Attachment attachment = page.getAttachmentNamed(filenameX);
To avoid sending events (which may provoked NPE in some cases) you can set it to a minor edit:
//store attachment //pdf is byte array (byte[]) AttachmentResource resource = new InputStreamAttachmentResource(new ByteArrayInputStream(pdf), filenameX, "application/pdf", pdf.length, "", true); fileUploadManager.storeResource(resource, page); //attachment is stored. to get info about attachment. Attachment attachment = page.getAttachmentNamed(filenameX);
Hi Pauls.. when i attach files via plugin, the page shows attachment and provides the link for attachment. But actually there is no attachment stored in the file system and the link is broken. It shows the following error: "The attachment you were trying to download could not be found in the attachment file store. Either the file has been deleted manually or there was an error in removing the record of the attachment from Confluence." If attachment is not stored, why is it showing in page. And what am i doing wrong!!! I simply used your 3 lines of code and i am also able to get attachmentId in plugin after uploading the file. Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.