s3file

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Bucket is the bucket name.
	Bucket string

	// Key is the key in s3 bucket.
	// One of Key or Source must be specified
	Key string

	// Source is the local file path. Used only by Write.
	Source string

	// Prefix is added to the Key attribute and used as final S3
	// bucket key.
	Prefix string

	// Content of the file. Used only by Write.
	Content io.ReadSeeker

	// ContentType is the content-type of file.
	ContentType string

	// MaxSize is the maximum size of Read or Write operation.
	MaxSize int64

	// VersionID is the version of S3 object. Used only
	// by Read.
	VersionID string

	// Region is the AWS region of the bucket.
	// File URL is constructed only if Region sepcified.
	Region string
}

Config represents the input configuration for file S3 file Read and Write functions.

type File

type File struct {
	// Bucket is the bucket of file.
	Bucket string

	// Key is the key of object in bucket.
	Key string

	// VersionID is the version of s3 object.
	VersionID string

	// Hash is the md5 of content in hex representation.
	Hash string

	// Body is the content of object. Set by Read function.
	Body io.ReadCloser

	// ContentType is the content-type header of s3 object.
	ContentType string

	// Region is the region of bucket.
	Region string

	// URL is the https URL of the file.
	// Example: https://s3.eu-central-1.amazonaws.com/mybucket/mykey
	URL string
}

File represents S3 Object

func Read

func Read(conn s3iface.S3API, c Config) (*File, error)

Read will read file specified by Config from S3.

func Write

func Write(conn s3iface.S3API, c Config) (*File, error)

Write writes an S3 object. If file exists and hash not changed, returns VersionID of existing file.

Jump to

Keyboard shortcuts

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