Last updated
Last updated
In this article, I would be showing you how to upload an attachment in a Confluence content using the "go-atlassian" library.
Create a new directory for your project.
Open a terminal and navigate to the project directory.
Initialize a new Go module using the following command:
In the terminal, run the following command to install the "go-atlassian" library:
Create a new Go file (e.g., main.go
) in your project directory.
Open the file and import the required packages:
In the main
function, create a new Confluence client and authenticate using your Atlassian URL, username, and API token:
Define the necessary variables for the page ID, file path, and file name:
Open the file using the provided file path:
Upload the attachment using the Content.Attachment.Create()
method and provide the page ID, file name, and file content:
Make sure to replace <CONFLUENCE_PAGE_ID>
, <FILE_PATH>
, and <FILE_NAME>
with the actual values for your use case.
Save the main.go
file.
In the terminal, navigate to your project directory.
Execute the following command to run the program:
This will upload the specified file as an attachment to the Confluence page with the provided page ID.