Skip to content

Commit

Permalink
docs: Adding an example for AddRemoteFile and DeleteFile (#1303)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzoaiello authored Jul 15, 2024
1 parent ecfe504 commit 7ddfd02
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/files_remote/files_remote.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 7ddfd02

Please sign in to comment.