mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-29 15:22:28 +02:00
nipb0: Add authorization headers to Blossom downloads
This commit is contained in:
committed by
fiatjaf_
parent
c9411a3c5b
commit
8140857879
@@ -21,6 +21,12 @@ func (c *Client) Download(ctx context.Context, hash string) ([]byte, error) {
|
||||
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
authHeader := c.authorizationHeader(ctx, func(evt *nostr.Event) {
|
||||
evt.Tags = append(evt.Tags, nostr.Tag{"t", "get"})
|
||||
evt.Tags = append(evt.Tags, nostr.Tag{"x", hash})
|
||||
})
|
||||
req.Header.Add("Authorization", authHeader)
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to call %s for %s: %w", c.mediaserver, hash, err)
|
||||
@@ -45,6 +51,12 @@ func (c *Client) DownloadToFile(ctx context.Context, hash string, filePath strin
|
||||
return fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
authHeader := c.authorizationHeader(ctx, func(evt *nostr.Event) {
|
||||
evt.Tags = append(evt.Tags, nostr.Tag{"t", "get"})
|
||||
evt.Tags = append(evt.Tags, nostr.Tag{"x", hash})
|
||||
})
|
||||
req.Header.Add("Authorization", authHeader)
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to call %s for %s: %w", c.mediaserver, hash, err)
|
||||
|
Reference in New Issue
Block a user