Monorepo for Tangled
tangled.org
1package blobstore
2
3import (
4 "context"
5 "fmt"
6 "io"
7 "net/http"
8
9 "github.com/bluesky-social/indigo/atproto/syntax"
10 "github.com/ipfs/go-cid"
11)
12
13type Porxie struct {
14 url string
15}
16
17func NewPorxieBlobStore(url string) *Porxie {
18 return &Porxie{url}
19}
20
21func (s *Porxie) GetBlob(ctx context.Context, did syntax.DID, cid cid.Cid) (io.ReadCloser, error) {
22 url := fmt.Sprintf("%s/%s/%s", s.url, did, cid)
23 resp, err := http.Get(url)
24 if err != nil {
25 return nil, err
26 }
27
28 if resp.StatusCode != http.StatusOK {
29 return nil, fmt.Errorf("unexpected status: %s", resp.Status)
30 }
31
32 return resp.Body, nil
33}