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

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)
}