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