Documentation ¶
Overview ¶
Package blobfs provides access with fs.FS interface to files stored in a blob storage.
FS implements fs.FS, so it can be used with any packages that understands file system interfaces. e.g.) net/http, text/template, html/template
It uses gocloud.dev/blob for a blob backend, so it can read the following blob storages.
- Google Cloud Storage - Amazon S3 - Azure Blob Storage - Local filesystem - In memory filesystem
For more details about gocloud.dev/blob, please refer to the following page. ref.) https://gocloud.dev/howto/blob/
Example (Fileblob) ¶
package main import ( "context" "fmt" "io" "log" "os" "gocloud.dev/blob" "github.com/ichizero/blobfs" _ "gocloud.dev/blob/fileblob" ) func main() { ctx := context.Background() dir, err := os.Getwd() if err != nil { log.Fatal(err) } bucket, err := blob.OpenBucket(ctx, fmt.Sprintf("file://%s/testdata", dir)) if err != nil { log.Fatal(err) } fsys := blobfs.New(bucket) f, err := fsys.Open("foo.txt") if err != nil { log.Fatal(err) } b, err := io.ReadAll(f) if err != nil { if err != io.EOF { log.Fatal(err) } } log.Print(string(b)) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
An FS is a read-only blob storage file system that implements fs.FS interface.
Click to show internal directories.
Click to hide internal directories.