add nipb0/blossom helpers.

This commit is contained in:
fiatjaf
2025-03-04 12:42:24 -03:00
parent 5bfaed2740
commit 5bafd1c778
8 changed files with 366 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
package blossom
import (
"context"
"fmt"
"github.com/nbd-wtf/go-nostr"
)
// Check checks if a file exists on the media server by its hash
func (c *Client) Check(ctx context.Context, hash string) error {
if !nostr.IsValid32ByteHex(hash) {
return fmt.Errorf("%s is not a valid 32-byte hex string", hash)
}
err := c.httpCall(ctx, "HEAD", c.mediaserver+"/"+hash, "", nil, nil, 0, nil)
if err != nil {
return fmt.Errorf("failed to check for %s: %w", hash, err)
}
return nil
}