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 10 months ago
all Docfix 10 months ago
cmd/storage Move drivers into subpackages 10 months ago
disk Docfix 10 months ago
ftp Docfix 10 months ago
google Docfix 10 months ago
internal/obscure Move drivers into subpackages 10 months ago
oauth2 Docfix 10 months ago
s3 Docfix 10 months ago
sftp Docfix 10 months ago
sql Move drivers into subpackages 10 months ago
testdata Moved project 10 months ago
vendor Vendored ftp client 10 months ago
webdav Docfix 10 months ago
.gitignore Moved project 10 months ago
Gopkg.lock Vendored ftp client 10 months ago
Gopkg.toml Initial import 10 months ago
LICENSE Initial commit 10 months ago
README.md Cleanup 10 months ago
config.go Move drivers into subpackages 10 months ago
config_test.go Move drivers into subpackages 10 months ago
ftp_test.go Move drivers into subpackages 10 months ago
glob.go Cleanup 10 months ago
memory.go Cleanup 10 months ago
sftp_test.go Move drivers into subpackages 10 months ago
storage.go Cleanup 10 months ago
storage_test.go Move drivers into subpackages 10 months ago
webdav_test.go Move drivers into subpackages 10 months 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)
}