s3

package
v0.0.0-...-e871f01 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2017 License: MIT Imports: 15 Imported by: 2

README

S3 plugin for WKFS

Package s3 registers an AWS S3 filesystem at the well-known /s3/ filesystem path.

Sample usage:

package main

import (
	"fmt"
	"io"
	"log"

	"github.com/nsheridan/wkfs/s3"
	"go4.org/wkfs"
)

func main() {
  opts := &s3.Options{
    Region: "us-east-1"
    AccessKey: "abcdef"
    SecretKey: "secret"
  }
  s3.Register(opts)
  f, err := wkfs.Create("/s3/some-bucket/hello.txt")
  if err != nil {
    log.Fatal(err)
  }
  _, err := io.WriteString(f, "hello, world")
  if err != nil {
    log.Fatal(err)
  }
}

Options are completely optional as the AWS SDK will attempt to obtain credentials from a number of locations - see the documentation for details - e.g. if you're using environment variables you can register the filesystem with s3.Register(nil).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(opts *Options)

Register the /s3/ filesystem as a well-known filesystem.

Types

type Options

type Options struct {
	Region    string
	AccessKey string
	SecretKey string
}

Options for registering the S3 wkfs. None of these are required and can be supplied to the aws client by other means.

type S3file

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

S3file represents a file in S3.

func NewS3file

func NewS3file(bucket, name string, s3api *s3.S3) (*S3file, error)

NewS3file initializes an S3file.

func (*S3file) Close

func (f *S3file) Close() error

Close the file, rendering it unusable.

func (*S3file) Write

func (f *S3file) Write(p []byte) (n int, err error)

Write len(p) bytes to the file in S3. It returns the number of bytes written and an error, if any.

Jump to

Keyboard shortcuts

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