Skip to content

Commit

Permalink
Add docs for platform specific type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbward authored and matryer committed Dec 15, 2016
1 parent ec1980f commit 1e39ea8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -3,7 +3,7 @@
[![GoDoc](https://godoc.org/github.com/graymeta/stow?status.svg)](https://godoc.org/github.com/graymeta/stow)
[![Go Report Card](https://goreportcard.com/badge/github.com/graymeta/stow)](https://goreportcard.com/report/github.com/graymeta/stow)

Cloud storage abstraction package for Go.
Cloud storage abstraction package for Go.

* Version: 0.1.0
* Project status: Stable. Approaching v1 release
Expand All @@ -27,7 +27,7 @@ Stow provides implementations for storage services, blob stores, cloud storage e

## Concepts

The concepts of Stow are modelled around the most popular object storage services, and are made up of three main objects:
The concepts of Stow are modeled around the most popular object storage services, and are made up of three main objects:

* `Location` - a place where many `Container` objects are stored
* `Container` - a named group of `Item` objects
Expand Down Expand Up @@ -84,6 +84,7 @@ import (
The underscore indicates that you do not intend to use the package in your code. Importing it is enough, as the implementation packages register themselves with Stow during initialization.

* For more information about using Stow, see the [Best practices documentation](BestPractices.md).
* Some implementation packages provide ways to access the underlying connection details for use-cases where more control over a specific service is needed. See the implementation package documentation for details.

### Connecting to locations

Expand Down
36 changes: 36 additions & 0 deletions google/README.md
Expand Up @@ -6,6 +6,42 @@ Container = Bucket

Item = File

## How to access underlying service types

Use a type conversion to extract the underlying `Location`, `Container`, or `Item` implementations. Then use the Google-specific getters to access the internal Google Cloud Storage `Service`, `Bucket`, and `Object` values.

```go
import (
"log"
"github.com/graymeta/stow"
stowgs "github.com/graymeta/stow/google"
)

stowLoc, err := stow.Dial(stowgs.Kind, stow.ConfigMap{
stowgs.ConfigJSON: "<json config>",
stowgs.ConfigProjectId: "<project id>",
})
if err != nil {
log.Fatal(err)
}

stowBucket, err = stowLoc.Container("mybucket")
if err != nil {
log.Fatal(err)
}

if gsBucket, ok := stowBucket.(*stowgs.Bucket); ok {
if gsLoc, ok := stowLoc.(*stowgs.Location); ok {

googleService := gsLoc.Service()
googleBucket := gsBucket.Bucket()

// < Send platform-specific commands here >

}
}
```

---

Configuration... You need to create a project in google, and then create a service account in google tied to that project. You will need to download a `.json` file with the configuration for the service account. To run the test suite, the service account will need edit privileges inside the project.
Expand Down

0 comments on commit 1e39ea8

Please sign in to comment.