https://github.com/ichizero/blobfs
Package blobfs provides access with fs.FS interface to files stored in a blob storage.
https://github.com/ichizero/blobfs
aws-s3 azure-storage-blob blob-storage gcp-storage go golang iofs
Last synced: 5 months ago
JSON representation
Package blobfs provides access with fs.FS interface to files stored in a blob storage.
- Host: GitHub
- URL: https://github.com/ichizero/blobfs
- Owner: ichizero
- License: mit
- Created: 2021-02-27T05:30:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-07T05:11:30.000Z (11 months ago)
- Last Synced: 2024-11-07T06:19:42.438Z (11 months ago)
- Topics: aws-s3, azure-storage-blob, blob-storage, gcp-storage, go, golang, iofs
- Language: Go
- Homepage:
- Size: 155 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# blobfs
[](https://github.com/ichizero/blobfs/actions/workflows/test.yml)
[](https://pkg.go.dev/github.com/ichizero/blobfs)
[](https://codecov.io/gh/ichizero/blobfs)
[](https://goreportcard.com/report/github.com/ichizero/blobfs)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 filesystemFor more details about gocloud.dev/blob, please refer to the following page.
ref.) https://gocloud.dev/howto/blob/## Example
```go
package blobfs_testimport (
"context"
"fmt"
"io"
"log"
"os""gocloud.dev/blob"
_ "gocloud.dev/blob/fileblob""github.com/ichizero/blobfs"
)func Example_fileblob() {
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")
b, err := io.ReadAll(f)
if err != nil {
if err != io.EOF {
log.Fatal(err)
}
}
log.Print(string(b))
}
```