s3util

package
v0.0.0-...-04ad16d Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2014 License: MIT, MIT Imports: 11 Imported by: 0

README

Package s3util provides streaming transfers to and from Amazon S3.

Full documentation:
http://godoc.org/github.com/kr/s3/s3util

Documentation

Overview

Package s3util provides streaming transfers to and from Amazon S3.

To use it, open or create an S3 object, read or write data, and close the object.

You must assign valid credentials to DefaultConfig.Keys before using DefaultConfig. Be sure to close an io.WriteCloser returned by this package, to flush buffers and complete the multipart upload process.

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Service: s3.DefaultService,
	Keys:    new(s3.Keys),
}

Functions

func Create

func Create(url string, h http.Header, c *Config) (io.WriteCloser, error)

Create creates an S3 object at url and sends multipart upload requests as data is written.

If h is not nil, each of its entries is added to the HTTP request header. If c is nil, Create uses DefaultConfig.

Example
package main

import (
	"github.com/kr/s3/s3util"
	"io"
	"os"
)

func main() {
	s3util.DefaultConfig.AccessKey = "...access key..."
	s3util.DefaultConfig.SecretKey = "...secret key..."
	r, _ := os.Open("/dev/stdin")
	w, _ := s3util.Create("https://mybucket.s3.amazonaws.com/log.txt", nil, nil)
	io.Copy(w, r)
	w.Close()
}
Output:

func Open

func Open(url string, c *Config) (io.ReadCloser, error)

Open requests the S3 object at url. An HTTP status other than 200 is considered an error.

If c is nil, Open uses DefaultConfig.

Example
package main

import (
	"github.com/kr/s3/s3util"
	"io"
	"os"
)

func main() {
	s3util.DefaultConfig.AccessKey = "...access key..."
	s3util.DefaultConfig.SecretKey = "...secret key..."
	r, _ := s3util.Open("https://mybucket.s3.amazonaws.com/log.txt", nil)
	w, _ := os.Create("out.txt")
	io.Copy(w, r)
	w.Close()
}
Output:

Types

type Config

type Config struct {
	*s3.Service
	*s3.Keys
	*http.Client // if nil, uses http.DefaultClient
}

Jump to

Keyboard shortcuts

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