Introduction
Cloudstorage is an library for working with Cloud Storage (Google, AWS, Azure) and SFTP, Local Files.
It provides a unified api for local files, sftp and Cloud files that aids testing and operating on multiple cloud storage.

Features
- Provide single unified api for multiple cloud (google, azure, aws) & local files.
- Cloud Upload/Download is unified in api so you don't have to download file to local, work with it, then upload.
- Buffer/Cache files from cloud local so speed of usage is very high.
Similar/Related works
Example usage:
Note: For these examples all errors are ignored, using the _
for them.
Creating a Store object:
config := &cloudstorage.Config{
Type: localfs.StoreType,
AuthMethod: localfs.AuthFileSystem,
LocalFS: "/tmp/mockcloud",
TmpDir: "/tmp/localcache",
}
store, _ := cloudstorage.NewStore(config)
Listing Objects:
See go Iterator pattern doc for api-design:
https://github.com/GoogleCloudPlatform/google-cloud-go/wiki/Iterator-Guidelines
q := cloudstorage.NewQuery("list-test/")
iter, err := store.Objects(context.Background(), q)
if err != nil {
}
for {
o, err := iter.Next()
if err == iterator.Done {
break
}
log.Println("found object ", o.Name())
}
Writing an object :
obj, _ := store.NewObject("prefix/test.csv")
f, _ := obj.Open(cloudstorage.ReadWrite)
w := bufio.NewWriter(f)
_, _ := w.WriteString("Year,Make,Model\n")
_, _ := w.WriteString("1997,Ford,E350\n")
w.Flush()
obj.Close()
Reading an existing object:
obj2, _ := store.Get(context.Background(), "prefix/test.csv")
f2, _ := obj2.Open(cloudstorage.ReadOnly)
bytes, _ := ioutil.ReadAll(f2)
fmt.Println(string(bytes))
Transferring an existing object:
var config = &storeutils.TransferConfig{
Type: google.StoreType,
AuthMethod: google.AuthGCEDefaultOAuthToken,
ProjectID: "my-project",
DestBucket: "my-destination-bucket",
Src: storeutils.NewGcsSource("my-source-bucket"),
IncludePrefxies: []string{"these", "prefixes"},
}
transferer, _ := storeutils.NewTransferer(client)
resp, _ := transferer.NewTransfer(config)
See testsuite.go for more examples
Testing
Due to the way integration tests act against a cloud bucket and objects; run tests without parallelization.
cd $GOPATH/src/github.com/lytics/cloudstorage
go test -p 1 ./...