mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-11-22 20:20:19 +01:00
Add Storj Storage Adapter - add Binding
This commit is contained in:
parent
59014f2110
commit
874268d80e
2 changed files with 36 additions and 1 deletions
34
cmd/cmd.go
34
cmd/cmd.go
|
@ -149,6 +149,26 @@ var globalFlags = []cli.Flag{
|
||||||
Usage: "",
|
Usage: "",
|
||||||
Value: googleapi.DefaultUploadChunkSize / 1024 / 1024,
|
Value: googleapi.DefaultUploadChunkSize / 1024 / 1024,
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "storj-endpoint",
|
||||||
|
Usage: "Satellite Address including Port.",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "storj-apikey",
|
||||||
|
Usage: "",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "storj-bucket",
|
||||||
|
Usage: "",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "storj-enckey",
|
||||||
|
Usage: "Encryption Key for local file encryption",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
cli.IntFlag{
|
cli.IntFlag{
|
||||||
Name: "rate-limit",
|
Name: "rate-limit",
|
||||||
Usage: "requests per minute",
|
Usage: "requests per minute",
|
||||||
|
@ -362,6 +382,20 @@ func New() *Cmd {
|
||||||
} else {
|
} else {
|
||||||
options = append(options, server.UseStorage(storage))
|
options = append(options, server.UseStorage(storage))
|
||||||
}
|
}
|
||||||
|
case "storj":
|
||||||
|
if endpoint := c.String("storj-endpoint"); endpoint == "" {
|
||||||
|
panic("storj-endpoint not set.")
|
||||||
|
} else if apiKey := c.String("storj-apikey"); apiKey == "" {
|
||||||
|
panic("storj-apikey not set.")
|
||||||
|
} else if bucket := c.String("storj-bucket"); bucket == "" {
|
||||||
|
panic("storj-enckey not set.")
|
||||||
|
} else if encKey := c.String("storj-enckey"); encKey == "" {
|
||||||
|
panic("storj-bucket not set.")
|
||||||
|
} else if storage, err := server.NewStorjStorage(endpoint, apiKey, bucket, encKey, logger); err != nil {
|
||||||
|
panic(err)
|
||||||
|
} else {
|
||||||
|
options = append(options, server.UseStorage(storage))
|
||||||
|
}
|
||||||
case "local":
|
case "local":
|
||||||
if v := c.String("basedir"); v == "" {
|
if v := c.String("basedir"); v == "" {
|
||||||
panic("basedir not set.")
|
panic("basedir not set.")
|
||||||
|
|
|
@ -572,7 +572,7 @@ type StorjStorage struct {
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorjStorage(endpoint, apiKey, bucket, encKey string) (*StorjStorage, error) {
|
func NewStorjStorage(endpoint, apiKey, bucket, encKey string, logger *log.Logger) (*StorjStorage, error) {
|
||||||
var instance StorjStorage
|
var instance StorjStorage
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -598,6 +598,7 @@ func NewStorjStorage(endpoint, apiKey, bucket, encKey string) (*StorjStorage, er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not open bucket %q: %v", bucket, err)
|
return nil, fmt.Errorf("could not open bucket %q: %v", bucket, err)
|
||||||
}
|
}
|
||||||
|
instance.logger = logger
|
||||||
|
|
||||||
return &instance, nil
|
return &instance, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue