Package storage offers generic (cloud) storage drivers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
maze 3b7ca50b79 Cleanup 2 years ago
all Docfix 2 years ago
cmd/storage Move drivers into subpackages 2 years ago
disk Docfix 2 years ago
ftp Docfix 2 years ago
google Docfix 2 years ago
internal/obscure Move drivers into subpackages 2 years ago
oauth2 Docfix 2 years ago
s3 Docfix 2 years ago
sftp Docfix 2 years ago
sql Move drivers into subpackages 2 years ago
testdata Moved project 2 years ago
vendor Vendored ftp client 2 years ago
webdav Docfix 2 years ago
.gitignore Moved project 2 years ago
Gopkg.lock Vendored ftp client 2 years ago
Gopkg.toml Initial import 2 years ago
LICENSE Initial commit 2 years ago
README.md Cleanup 2 years ago
config.go Move drivers into subpackages 2 years ago
config_test.go Move drivers into subpackages 2 years ago
ftp_test.go Move drivers into subpackages 2 years ago
glob.go Cleanup 2 years ago
memory.go Cleanup 2 years ago
sftp_test.go Move drivers into subpackages 2 years ago
storage.go Cleanup 2 years ago
storage_test.go Move drivers into subpackages 2 years ago
webdav_test.go Move drivers into subpackages 2 years ago

README.md

storage

Package storage offers generic (cloud) storage drivers.

Drivers

Supported drivers are as follows:

Driver Description
disk Local disk.
ftp FTP storage.
google Google Drive storage.
minio Minio storage.
s3 Amazon S3 storage.
sftp SFTP server storage (over SSH).
stack TransIP Stack storage.
webdav WebDAV server storage.

Usage

In order to use one of the supported storage backends, you need to import the appropriate driver and supply a configuration like follows:

package main

import (
    "fmt"

    "maze.io/x/storage"
    _ "maze.io/x/storage/disk" // Local disk driver
)

func main() {
    config := storage.Config{
        Type:   "disk",
        Config: map[string]interface{}{
            "path": "/tmp",
        },
    }

    backend, err := config.Open()
    if err != nil {
        panic(err)
    }

    fmt.Printf("using storage %s\n", backend)
}

The storage.Config struct exists to facilitate loading storage configurations from structured configuration formats, such as JSON or YAML:

package main

import (
    "encoding/json"
    "fmt"

    "maze.io/x/storage"
    _ "maze.io/x/storage/disk" // Local disk driver
)

func main() {
    var config storage.Config
    if err := json.Unmarshal([]byte(configFile), &config); err != nil {
        panic(err)
    }

    backend, err := config.Open()
    if err != nil {
        panic(err)
    }

    fmt.Printf("using storage %s\n", backend)
}

const configFile = `{
    "type": "disk",
    "config": {
        "path": "/"
    }
}`

You can also use the driver directly:

package main

import (
    "fmt"

    "maze.io/x/storage/disk" // Local disk driver
)

func main() {
    config := disk.Config{
        Path: "/tmp",
    }

    backend, err := config.Open()
    if err != nil {
        panic(err)
    }

    fmt.Printf("using storage %s\n", backend)
}