Documentation ¶
Overview ¶
Package upspinfsys provides an implementation of fs.FS interface for Upspin. It implements the fs.FS interface and the necessary methods to serve it using the http.FileServer too.
Limitations:
- The FileMode does not represent the Access file correctly.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpspinFS ¶
UpspinFS returns a fs.FS implementation. To use the Open function is necessary to pass the full path of the file (the file system is not rooted at client's home).
Example ¶
fsys := upspinfsys.UpspinFS(c) home := string(cfg.UserName()) path := filepath.Join(home, "documents", "doc1.txt") f, err := fsys.Open(path) if err != nil { log.Fatal(err) } data, err := io.ReadAll(f) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", data)
Output: doc1
Example (HttpServer) ¶
fsys := upspinfsys.UpspinFS(c) home := string(cfg.UserName()) path := filepath.Join(home, "documents", "doc2.txt") go func() { http.Handle("/", http.FileServer(http.FS(fsys))) http.ListenAndServe(":8080", nil) }() resp, err := http.Get("http://localhost:8080/" + path) if err != nil { log.Fatal(err) } defer resp.Body.Close() data, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", data)
Output: doc2
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.