From f1659484093c3e6a4f1b2e35ff458b6a0877e41a Mon Sep 17 00:00:00 2001 From: Kaiyuan Liu Date: Sun, 26 Sep 2021 04:46:00 +0800 Subject: [PATCH 1/2] Add example for storj --- new_storj.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 new_storj.go diff --git a/new_storj.go b/new_storj.go new file mode 100644 index 0000000..b23a3e0 --- /dev/null +++ b/new_storj.go @@ -0,0 +1,38 @@ +package example + +import ( + "fmt" + "os" + + storj "github.com/beyondstorage/go-service-storj" + "github.com/beyondstorage/go-storage/v4/pairs" + "github.com/beyondstorage/go-storage/v4/services" + "github.com/beyondstorage/go-storage/v4/types" +) + +func NewSTORJ() (types.Storager, error) { + return storj.NewStorager( + // work_dir: https://beyondstorage.io/docs/go-storage/pairs/work_dir + // + // Relative operations will be based on this WorkDir. + pairs.WithWorkDir(os.Getenv("STORAGE_STORJ_WORKDIR")), + // endpoint: https://beyondstorage.io/docs/go-storage/pairs/credential + // + // Example Value: apikey:apikey_value + pairs.WithCredential(os.Getenv("STORAGE_STORJ_CREDENTIAL")), + // name: https://beyondstorage.io/docs/go-storage/pairs/name + // + // name is the bucket name. + pairs.WithName(os.Getenv("STORAGE_STORJ_NAME")), + ) +} + +func NewSTORJFromString() (types.Storager, error) { + connStr := fmt.Sprintf( + "storj://%s%s?credential=%s", + os.Getenv("STORAGE_STORJ_NAME"), + os.Getenv("STORAGE_STORJ_WORKDIR"), + os.Getenv("STORAGE_STORJ_CREDENTIAL"), + ) + return services.NewStoragerFromString(connStr) +} From 74f23aa72231bf98f386718890e97db733216af4 Mon Sep 17 00:00:00 2001 From: Kaiyuan Liu Date: Mon, 27 Sep 2021 11:19:44 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9557da1..16a57cb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ - [Create gdrive Storager](new_gdrive.go) (Google Drive) - [Create obs Storager](new_obs.go) (Huawei Object Storage Service) - [Create s3 Storager](new_s3.go) (Amazon S3) - +- [Create storj Storager](new_storj.go) (Storj) ## Basic Operations ### List files