fs

package
v0.0.0-...-aa28848 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) (err error)

http://stackoverflow.com/a/21067803 CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.

Types

type Backend

type Backend struct {
	sync.RWMutex

	Bytes int64 `json:"bytes"`

	Log *log.Logger `json:"-"`
	// contains filtered or unexported fields
}

func InitBackend

func InitBackend(baseurl string, filedir string, tempdir string, expiration int64, log *log.Logger, filters []string) (Backend, error)

func (*Backend) BinExists

func (be *Backend) BinExists(bin string) bool

func (*Backend) DeleteBin

func (be *Backend) DeleteBin(bin string) (Bin, error)

func (*Backend) DeleteFile

func (be *Backend) DeleteFile(bin string, filename string) (File, error)
func (be *Backend) GenerateLinks(bin string, filename string) []Link

func (*Backend) GenerateThumbnail

func (be *Backend) GenerateThumbnail(bin string, filename string, width int, height int, crop bool) error

func (*Backend) GetBinArchive

func (be *Backend) GetBinArchive(bin string, format string, w http.ResponseWriter) (io.Writer, string, error)

func (*Backend) GetBinMetaData

func (be *Backend) GetBinMetaData(bin string) (Bin, error)

func (*Backend) GetBins

func (be *Backend) GetBins() []string

func (*Backend) GetBinsMetaData

func (be *Backend) GetBinsMetaData() []Bin

func (*Backend) GetFile

func (be *Backend) GetFile(bin string, filename string) (io.ReadSeeker, error)

func (*Backend) GetFileMetaData

func (be *Backend) GetFileMetaData(bin string, filename string) (File, error)

func (*Backend) GetFiles

func (be *Backend) GetFiles(bin string) []string

func (*Backend) GetThumbnail

func (be *Backend) GetThumbnail(bin string, filename string, width int, height int) (io.ReadSeeker, error)

func (*Backend) Info

func (be *Backend) Info() string

func (*Backend) NewBin

func (be *Backend) NewBin(bin string) Bin

func (*Backend) UploadFile

func (be *Backend) UploadFile(bin string, filename string, data io.ReadCloser) (File, error)

type Bin

type Bin struct {
	Bin             string    `json:"bin"`
	Bytes           int64     `json:"bytes"`
	BytesReadable   string    `json:"-"`
	ExpiresAt       time.Time `json:"expires"`
	ExpiresReadable string    `json:"-"`
	Expired         bool      `json:"-"`
	UpdatedAt       time.Time `json:"updated"`
	UpdatedReadable string    `json:"-"`
	Files           []File    `json:"files,omitempty"`
	Album           bool      `json:"-"`
}

type BinsByUpdatedAt

type BinsByUpdatedAt []Bin

Sort bins by Update At

func (BinsByUpdatedAt) Len

func (a BinsByUpdatedAt) Len() int

func (BinsByUpdatedAt) Less

func (a BinsByUpdatedAt) Less(i, j int) bool

func (BinsByUpdatedAt) Swap

func (a BinsByUpdatedAt) Swap(i, j int)

type File

type File struct {
	Filename  string    `json:"filename"`
	Bin       string    `json:"bin"`
	Bytes     int64     `json:"bytes"`
	MIME      string    `json:"mime"`
	CreatedAt time.Time `json:"created"`
	Links     []Link    `json:"links"`

	// Image specific attributes
	DateTime  time.Time `json:"datetime,omitempty"`
	Longitude float64   `json:"longitude,omitempty"`
	Latitude  float64   `json:"latitude,omitempty"`
}

func (File) BytesReadable

func (f File) BytesReadable() string

func (File) CreatedReadable

func (f File) CreatedReadable() string

func (*File) DateTimeReadable

func (f *File) DateTimeReadable() string

func (*File) DateTimeString

func (f *File) DateTimeString() string
func (f *File) GetLink(s string) string

func (*File) MediaType

func (f *File) MediaType() string

type FilesByDateTime

type FilesByDateTime []File

Sort files by DateTime

func (FilesByDateTime) Len

func (a FilesByDateTime) Len() int

func (FilesByDateTime) Less

func (a FilesByDateTime) Less(i, j int) bool

func (FilesByDateTime) Swap

func (a FilesByDateTime) Swap(i, j int)

type FilesByFilename

type FilesByFilename []File

Sort files by filename

func (FilesByFilename) Len

func (a FilesByFilename) Len() int

func (FilesByFilename) Less

func (a FilesByFilename) Less(i, j int) bool

func (FilesByFilename) Swap

func (a FilesByFilename) Swap(i, j int)
type Link struct {
	Rel  string `json:"rel"`
	Href string `json:"href"`
}

Jump to

Keyboard shortcuts

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