coffrify-go
Official Go SDK for Coffrify — encrypted file transfer infrastructure.
Install
go get github.com/coffrify/coffrify-go
Quickstart
package main
import (
"context"
"fmt"
"log"
coffrify "github.com/coffrify/coffrify-go/coffrify"
)
func main() {
client := coffrify.New("cfy_live_...") // or os.Getenv("COFFRIFY_API_KEY")
ctx := context.Background()
transfer, err := client.Transfers.Create(ctx, &coffrify.CreateTransferParams{
Files: []coffrify.File{
{Name: "rapport.pdf", Size: 1_240_000, MimeType: "application/pdf"},
},
ExpiresInHours: 72,
MaxDownloads: 10,
Password: "secret",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Share URL:", transfer["share_url"])
}
Webhook verification
import (
"io"
"net/http"
coffrify "github.com/coffrify/coffrify-go/coffrify"
)
func handleWebhook(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body)
result := coffrify.VerifyWebhook(
string(body),
r.Header.Get("X-Coffrify-Signature"),
os.Getenv("COFFRIFY_WEBHOOK_SECRET"),
300, // 5 min tolerance
)
if !result.Valid {
http.Error(w, result.Reason, http.StatusBadRequest)
return
}
eventType := result.Event["type"].(string)
// ...
w.WriteHeader(http.StatusOK)
}
License
MIT