files

package
v0.0.0-...-779d743 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFilesAPI

func NewFilesAPI(source Source) http.Handler

NewFilesAPI returns a new http.Handler instance that implements files related endpoints.

Types

type Item

type Item struct {
	Type     ItemType  `json:"type"`
	Name     string    `json:"name"`
	Path     string    `json:"path"`
	ModTime  time.Time `json:"updated_at"`
	Children []*Item   `json:"children"`
}

Item represents a single source file.

type ItemType

type ItemType string

ItemType defines entity types supported by sources.

const (
	// ItemTypeFile represents files.
	ItemTypeFile ItemType = "file"
	// ItemTypeDirectory represents directories.
	ItemTypeDirectory ItemType = "directory"
)

type Source

type Source interface {
	Tree() (*Item, error)
	Mkdir(path string) (*Item, error)
	Rmdir(path string) (*Item, error)
	File(filePath string) (*os.File, error)
	Save(r io.Reader, filePath string) (*Item, error)
	Remove(filePath string) (*Item, error)
}

Source provides album and images metadata.

func NewDiskSource

func NewDiskSource(basePath string) (Source, error)

NewDiskSource returns disk based source for a provided base dir path. Only images with requested extensions are returned.

Jump to

Keyboard shortcuts

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