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