Copy package main
import (
"context"
"fmt"
confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
"log"
"os"
)
func main () {
var (
host = os. Getenv ( "HOST" )
mail = os. Getenv ( "MAIL" )
token = os. Getenv ( "TOKEN" )
)
instance, err := confluence. New ( nil , host)
if err != nil {
log. Fatal (err)
}
instance.Auth. SetBasicAuth (mail, token)
instance.Auth. SetUserAgent ( "curl/7.54.0" )
attachment, response, err := instance.Attachment. Get (context. Background (), "att219152391" , 0 , false )
if err != nil {
if response != nil {
log. Println (response.Endpoint)
log. Println (response.Code)
log. Println (response.Bytes. String ())
}
log. Fatal (err)
}
fmt. Print (attachment)
}
Gets returns the attachments of specific entity type.
Copy package main
import (
"context"
"fmt"
confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"os"
)
func main () {
var (
host = os. Getenv ( "HOST" )
mail = os. Getenv ( "MAIL" )
token = os. Getenv ( "TOKEN" )
)
instance, err := confluence. New ( nil , host)
if err != nil {
log. Fatal (err)
}
instance.Auth. SetBasicAuth (mail, token)
instance.Auth. SetUserAgent ( "curl/7.54.0" )
options := & models . AttachmentParamsScheme {
Sort: "" ,
MediaType: "" ,
FileName: "" ,
SerializeIDs: false ,
}
attachments, response, err := instance.Attachment. Gets (context. Background (), 65798145 , "pages" , options, "" , 50 )
if err != nil {
if response != nil {
log. Println (response.Endpoint)
log. Println (response.Code)
log. Println (response.Bytes. String ())
}
log. Fatal (err)
}
for _, attachment := range attachments.Results {
fmt. Println (attachment.ID, attachment.Title)
}
}
Delete an attachment by id.
Copy package main
import (
"context"
confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
"log"
"os"
)
func main () {
var (
host = os. Getenv ( "HOST" )
mail = os. Getenv ( "MAIL" )
token = os. Getenv ( "TOKEN" )
)
instance, err := confluence. New ( nil , host)
if err != nil {
log. Fatal (err)
}
instance.Auth. SetBasicAuth (mail, token)
instance.Auth. SetUserAgent ( "curl/7.54.0" )
response, err := instance.Attachment. Delete (context. Background (), "att219152391" )
if err != nil {
if response != nil {
log. Println (response.Endpoint)
log. Println (response.Code)
log. Println (response.Bytes. String ())
}
log. Fatal (err)
}
}