From 91d7bf10f248f7ec1130a58d16b4358bc12084d1 Mon Sep 17 00:00:00 2001 From: Lorenzo Aiello Date: Sun, 14 Jul 2024 18:39:23 -0700 Subject: [PATCH] docs: Adding an example for AddRemoteFile and DeleteFile --- examples/files_remote/files_remote.go | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/files_remote/files_remote.go diff --git a/examples/files_remote/files_remote.go b/examples/files_remote/files_remote.go new file mode 100644 index 000000000..60bcfa967 --- /dev/null +++ b/examples/files_remote/files_remote.go @@ -0,0 +1,30 @@ +package main + +import ( + "context" + "fmt" + + "github.com/slack-go/slack" +) + +func main() { + api := slack.New("YOUR_TOKEN") + params := slack.RemoteFileParameters{ + Title: "My File", + ExternalID: "my-file-123", + ExternalURL: "https://raw.githubusercontent.com/slack-go/slack/master/README.md", + } + file, err := api.AddRemoteFileContext(context.Background(), params) + if err != nil { + fmt.Printf("%s\n", err) + return + } + fmt.Printf("Name: %s, URL: %s\n", file.Name, file.URLPrivate) + + err = api.DeleteFileContext(context.Background(), file.ID) + if err != nil { + fmt.Printf("%s\n", err) + return + } + fmt.Printf("File %s deleted successfully.\n", file.Name) +}