๐Upload Content Attachment
In this article, I would be showing you how to upload an attachment in a Confluence content using the "go-atlassian" library.
Step 1: Set up the project
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:
Step 2: Install the "go-atlassian" library
In the terminal, run the following command to install the "go-atlassian" library:
Step 3: Import the necessary packages
Create a new Go file (e.g.,
main.go
) in your project directory.Open the file and import the required packages:
Step 4: Authenticate with Confluence
In the main
function, create a new Confluence client and authenticate using your Atlassian URL, username, and API token:
Step 5: Upload an attachment to a Confluence page
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.
Step 6: Run the program
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.
Last updated