Documentation ¶
Overview ¶
Package mem implements in memory file system
Index ¶
- Constants
- func New(options ...storage.Option) storage.Manager
- func NewStorager(baseURL string) storage.Storager
- func Provider(options ...storage.Option) (storage.Manager, error)
- func ResetSingleton(options ...storage.Option)
- func Singleton(options ...storage.Option) storage.Manager
- func Split(URL string) (string, string)
- func SplitPath(URLPath string) []string
- type File
- type Folder
- func (f *Folder) Delete(name string) error
- func (f *Folder) File(URL string) (*File, error)
- func (f *Folder) Folder(URL string, mkdirMode os.FileMode) (*Folder, error)
- func (f *Folder) Lookup(URL string, mkdirMode os.FileMode) (storage.Object, error)
- func (f *Folder) Objects() []storage.Object
- func (f *Folder) Put(object storage.Object) error
Examples ¶
Constants ¶
View Source
const Scheme = "mem"
Scheme memory URL scheme
Variables ¶
This section is empty.
Functions ¶
func New ¶
New create a in memory storage
Example ¶
package main import ( "context" "fmt" "github.com/viant/afs/mem" "log" "strings" ) func main() { manager := mem.New() ctx := context.Background() err := manager.Upload(ctx, "mem://localhost/folder1/asset.txt", 0644, strings.NewReader("some content")) if err != nil { log.Fatal(err) } objects, err := manager.List(ctx, "mem://localhost/folder1/") if err != nil { log.Fatal(err) } for _, object := range objects { fmt.Printf("%v %v\n", object.URL(), object.Name()) } }
Output:
func NewStorager ¶
NewStorager create a new in memeory storage service
Example ¶
package main import ( "context" "fmt" "github.com/viant/afs/mem" "log" "strings" ) func main() { ctx := context.Background() storager := mem.NewStorager("mem://localhost/") err := storager.Upload(ctx, "folder1/asset1", 0644, strings.NewReader("some content")) if err != nil { log.Fatal(err) } err = storager.Upload(ctx, "folder1/asset2", 0644, strings.NewReader("some content")) if err != nil { log.Fatal(err) } fileInfos, err := storager.List(ctx, "folder1/", 0, 0) if err != nil { log.Fatal(err) } for _, info := range fileInfos { fmt.Printf("%v\n", info.Name()) } }
Output:
Types ¶
type Folder ¶
Folder represents memory folder
func (*Folder) Folder ¶
Folder returns a folder for supplied URL, when mkdirMode is non zero it will create missing folders with supplied mode
Click to show internal directories.
Click to hide internal directories.