mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-17 19:13:56 +02:00
nip96: http file storage
This commit is contained in:
33
nip96/nip96_test.go
Normal file
33
nip96/nip96_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package nip96
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
func TestUpload(t *testing.T) {
|
||||
img, _ := os.Open("./testdata/image.png")
|
||||
defer img.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
resp, err := Upload(ctx, UploadRequest{
|
||||
Host: "https://nostr.build/api/v2/nip96/upload",
|
||||
//Host: "https://nostrcheck.me/api/v2/media",
|
||||
//Host: "https://nostrage.com/api/v2/media",
|
||||
SK: nostr.GeneratePrivateKey(),
|
||||
File: img,
|
||||
Filename: "ostrich.png",
|
||||
Caption: "nostr ostrich",
|
||||
ContentType: "image/png",
|
||||
NoTransform: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err, "client.Upload")
|
||||
}
|
||||
|
||||
t.Logf("resp: %#v\n", *resp)
|
||||
// nip96_test.go:28: resp: nip96.UploadResponse{Status:"success", Message:"Upload successful.", ProcessingURL:"", Nip94Event:struct { Tags nostr.Tags "json:\"tags\"" }{Tags:nostr.Tags{nostr.Tag{"url", "https://image.nostr.build/4ece05f1d77c9cb97d334ba9c0301b2960640df89bf5d75d6bffadefc4355673.jpg"}, nostr.Tag{"ox", "4ece05f1d77c9cb97d334ba9c0301b2960640df89bf5d75d6bffadefc4355673"}, nostr.Tag{"x", ""}, nostr.Tag{"m", "image/jpeg"}, nostr.Tag{"dim", "1125x750"}, nostr.Tag{"bh", "LLF=kB-;yH-;-;R#t7xKEZWA#_oM"}, nostr.Tag{"blurhash", "LLF=kB-;yH-;-;R#t7xKEZWA#_oM"}, nostr.Tag{"thumb", "https://image.nostr.build/thumb/4ece05f1d77c9cb97d334ba9c0301b2960640df89bf5d75d6bffadefc4355673.jpg"}}}}
|
||||
}
|
Reference in New Issue
Block a user