Skip to content

Commit

Permalink
added http.Filesystem adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Oct 7, 2023
1 parent a331498 commit b635d6c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions adapter/http/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ package http
import (
"context"
"github.com/viant/afs"
"github.com/viant/afs/url"
"net/http"
)

type Filesystem struct {
fs afs.Service
fs afs.Service
dir string
}

func (f *Filesystem) Open(name string) (http.File, error) {
object, err := f.fs.Object(context.Background(), name)
object, err := f.fs.Object(context.Background(), url.Join(f.dir, name))
if err != nil {
return nil, err
}
return NewFile(object, f.fs)
}

// New creates http filesystem
func New(fs afs.Service) http.FileSystem {
return &Filesystem{fs: fs}
func New(fs afs.Service, dir string) http.FileSystem {
return &Filesystem{fs: fs, dir: dir}
}

0 comments on commit b635d6c

Please sign in to comment.