A Go client for interacting with UploadThing – supports file uploads, listing, deletion, and metadata operations.
go get github.com/r0ld3x/utapi-go- ✅ Upload files to UploadThing
- 📄 List uploaded files
- 🔄 Rename files
- 🗑️ Delete files
- 📆 Fetch file info
- 🛡️ Typed API responses
- Apikey format:
sk_*************************
import "github.com/r0ld3x/utapi-go"
cfg := utapi.Config{
ApiKey: "sk_*************************",
}
client := utapi.NewUtApi(cfg)fileInfo, err := utapi.GetFileInfo("example.pdf")
if err != nil {
log.Fatal(err)
}
uploadOpts := utapi.PrepareUploadOpt{
Files: []utapi.FileRequest{*fileInfo},
}
resp, err := client.PrepareUpload(uploadOpts)
if err != nil {
log.Fatal(err)
}
err = client.UploadFile(&resp[0], "example.pdf")
if err != nil {
log.Fatal(err)
}files, err := client.ListFiles(utapi.ListFilesOpts{})
if err != nil {
log.Fatal(err)
}
fmt.Println("Files:", files)renameOpts := utapi.RenameRequest{
Updates: []utapi.RenameUpdate{
{
NewName: "renamed.pdf",
FileKey: "your-file-key",
},
},
}
err := client.RenameFiles(renameOpts)
if err != nil {
log.Fatal(err)
}deleteOpts := utapi.DeleteFilesOpt{
FileKeys: []string{"your-file-key"},
}
err := client.DeleteFiles(deleteOpts)
if err != nil {
log.Fatal(err)
}Inline GoDocs are available at pkg.go.dev/github.com/r0ld3x/utapi-go Or run locally with:
godoc -http=:6060Pull requests and issues are welcome! Please ensure code is linted and tested.
MIT © r0ld3x