s3ow

package module
v0.0.0-...-841cb3b Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

README

S3 Object Writer

Go Reference

Write objects directly to AWS S3-like storages without requiring any intermediary files.

How It Works

Installation

Install s3ow using the go get command:

$ go get github.com/hjr265/s3ow

Usage

Creating and uploading a ZIP to S3:

s, _ := session.NewSession()
ow := s3ow.New(s, s3ow.Bucket(""), s3ow.Key(""))
zw := zip.NewWriter(ow)
// Add stuff to zip.
zw.Close()
ow.Close() // Returns nil after upload is complete, or error.

Contributing

Contributions are welcome.

License

This Go package (s3ow) is available under the BSD (3-Clause) License.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	Apply(*Writer)
}

func ACL

func ACL(acl string) Option

func Bucket

func Bucket(bucket string) Option

func ContentDisposition

func ContentDisposition(value string) Option

func Key

func Key(key string) Option

type OptionFunc

type OptionFunc func(*Writer)

func (OptionFunc) Apply

func (o OptionFunc) Apply(w *Writer)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}
Example
package main

import (
	"archive/zip"

	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/hjr265/s3ow"
)

func main() {
	s, _ := session.NewSession()
	ow := s3ow.New(s, s3ow.Bucket(""), s3ow.Key(""))
	zw := zip.NewWriter(ow)
	// Add stuff to zip.
	zw.Close()
	ow.Close() // Returns nil after upload is complete, or error.
}
Output:

func New

func New(c client.ConfigProvider, opts ...Option) *Writer

New returns an object writer that satisfies io.WriteCloser.

func (*Writer) Close

func (w *Writer) Close() error

Close marks the EOF for this upload, waits until the upload finishes, and returns error if any.

func (*Writer) Output

func (w *Writer) Output() *s3manager.UploadOutput

Output returns the output from the upload call to s3manager. This should be called after Close returns.

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Write passes b to s3manager to upload.

Jump to

Keyboard shortcuts

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