s3browser

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 15 Imported by: 0

README

Caddy s3browser

Example config

dl.example.com {
	s3browser {
		key ADDKEYHERE
		secret ADDSECRETHERE
		bucket ADDBUCKETHERE
		endpoint nyc3.digitaloceanspaces.com
		secure true
		refresh 5m
		debug false
	}
	proxy / https://examplebucket.nyc3.digitaloceanspaces.com {
		header_upstream Host examplebucket.nyc3.digitaloceanspaces.com
	}
}

This will provide directory listing for an S3 bucket (you are able to use minio, or other S3 providers). To serve files via Caddy as well you'll need to use the proxy directive as well. The server must be able to have public access to the files in the bucket.

Note: For performance reasons, the file listing is fetched once every 5minutes to reduce load on S3 (or S3 equivalent).

Prior Art

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolArg

func BoolArg(c *caddy.Controller) (bool, error)

func DurationArg

func DurationArg(c *caddy.Controller) (time.Duration, error)

func StringArg

func StringArg(c *caddy.Controller) (string, error)

Assert only one arg and return it

Types

type Browse

type Browse struct {
	Next     httpserver.Handler
	Config   Config
	Client   *minio.Client
	Fs       map[string]Directory
	Template *template.Template
}

func (Browse) ServeHTTP

func (b Browse) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)

type Config

type Config struct {
	Key            string
	Bucket         string
	Secret         string
	Endpoint       string
	Secure         bool
	Refresh        time.Duration
	AllowDownloads bool
	Debug          bool
}

type Directory

type Directory struct {
	Path    string
	Folders []Folder
	Files   []File
}

func (Directory) Breadcrumbs

func (d Directory) Breadcrumbs() []Node

func (Directory) ReadableName

func (d Directory) ReadableName() string

type File

type File struct {
	Folder string
	Bytes  int64
	Name   string
	Date   time.Time
}

func (File) HumanModTime

func (f File) HumanModTime(format string) string

HumanModTime returns the modified time of the file as a human-readable string.

func (File) HumanSize

func (f File) HumanSize() string

HumanSize returns the size of the file as a human-readable string in IEC format (i.e. power of 2 or base 1024).

type Folder

type Folder struct {
	Name string
}

func (Folder) ReadableName

func (f Folder) ReadableName() string

type Node

type Node struct {
	Link         string
	ReadableName string
}

Jump to

Keyboard shortcuts

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