pathio

package module
v3.1.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2016 License: Apache-2.0 Imports: 8 Imported by: 5

README

pathio

-- import "github.com/Clever/pathio"

Package pathio is a package that allows writing to and reading from different types of paths transparently. It supports two types of paths:

1. Local file paths
2. S3 File Paths (s3://bucket/key)

Note that using s3 paths requires setting two environment variables

1. AWS_SECRET_ACCESS_KEY
2. AWS_ACCESS_KEY_ID

Usage

var DefaultClient = &Client{}

DefaultClient is the default pathio client called by the Reader, Writer, and WriteReader methods. It has S3 encryption enabled.

func Reader
func Reader(path string) (rc io.ReadCloser, err error)

Reader Calls DefaultClient's Reader method.

func Write
func Write(path string, input []byte) error

Write Calls DefaultClient's Write method.

func WriteReader
func WriteReader(path string, input io.ReadSeeker) error

WriteReader Calls DefaultClient's WriteReader method.

type Client
type Client struct {
}

Client is the pathio client used to access the local file system and S3. It includes an option to disable S3 encryption. To disable S3 encryption, create a new Client and call it directly: &Client{disableS3Encryption: true}.Write(...)

func (*Client) Reader
func (c *Client) Reader(path string) (rc io.ReadCloser, err error)

Reader returns an io.Reader for the specified path. The path can either be a local file path or an S3 path. It is the caller's responsibility to close rc.

func (*Client) Write
func (c *Client) Write(path string, input []byte) error

Write writes a byte array to the specified path. The path can be either a local file path or an S3 path.

func (*Client) WriteReader
func (c *Client) WriteReader(path string, input io.ReadSeeker) error

WriteReader writes all the data read from the specified io.Reader to the output path. The path can either a local file path or an S3 path.

Documentation

Overview

Package pathio is a package that allows writing to and reading from different types of paths transparently. It supports two types of paths:

  1. Local file paths
  2. S3 File Paths (s3://bucket/key)

Note that using s3 paths requires setting two environment variables

  1. AWS_SECRET_ACCESS_KEY
  2. AWS_ACCESS_KEY_ID

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &Client{}

DefaultClient is the default pathio client called by the Reader, Writer, and WriteReader methods. It has S3 encryption enabled.

Functions

func Reader

func Reader(path string) (rc io.ReadCloser, err error)

Reader Calls DefaultClient's Reader method.

func Write

func Write(path string, input []byte) error

Write Calls DefaultClient's Write method.

func WriteReader

func WriteReader(path string, input io.ReadSeeker) error

WriteReader Calls DefaultClient's WriteReader method.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the pathio client used to access the local file system and S3. It includes an option to disable S3 encryption. To disable S3 encryption, create a new Client and call it directly: `&Client{disableS3Encryption: true}.Write(...)`

func (*Client) Reader

func (c *Client) Reader(path string) (rc io.ReadCloser, err error)

Reader returns an io.Reader for the specified path. The path can either be a local file path or an S3 path. It is the caller's responsibility to close rc.

func (*Client) Write

func (c *Client) Write(path string, input []byte) error

Write writes a byte array to the specified path. The path can be either a local file path or an S3 path.

func (*Client) WriteReader

func (c *Client) WriteReader(path string, input io.ReadSeeker) error

WriteReader writes all the data read from the specified io.Reader to the output path. The path can either a local file path or an S3 path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL