xfs

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanOutdatedFiles

func CleanOutdatedFiles(xfs XFS, before time.Time, loggers ...log.Logger)

func CleanOutdatedLocalFiles

func CleanOutdatedLocalFiles(dir string, before time.Time, loggers ...log.Logger)

func HFS

func HFS(xfs XFS) http.FileSystem

HFS converts xfs to a http.FileSystem implementation.

Types

type FSFile

type FSFile struct {
	XFS  XFS
	File *File
	// contains filtered or unexported fields
}

FSFile implements fs.File interface

func (*FSFile) Close

func (f *FSFile) Close() error

func (*FSFile) Read

func (f *FSFile) Read(p []byte) (int, error)

func (*FSFile) Readdir

func (f *FSFile) Readdir(count int) ([]fs.FileInfo, error)

func (*FSFile) Seek

func (f *FSFile) Seek(offset int64, whence int) (int64, error)

func (*FSFile) Stat

func (f *FSFile) Stat() (fs.FileInfo, error)

type FSFileInfo

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

FSFileInfo implements fs.FileInfo interface

func (*FSFileInfo) IsDir

func (fi *FSFileInfo) IsDir() bool

abbreviation for Mode().IsDir()

func (*FSFileInfo) ModTime

func (fi *FSFileInfo) ModTime() time.Time

modification time

func (*FSFileInfo) Mode

func (fi *FSFileInfo) Mode() fs.FileMode

file mode bits

func (*FSFileInfo) Name

func (fi *FSFileInfo) Name() string

base name of the file

func (*FSFileInfo) Size

func (fi *FSFileInfo) Size() int64

length in bytes for regular files; system-dependent for others

func (*FSFileInfo) Sys

func (fi *FSFileInfo) Sys() any

underlying data source (can return nil)

type File

type File struct {
	ID   string    `gorm:"size:256;not null;primaryKey" json:"id"`
	Name string    `gorm:"not null;" json:"name"`
	Ext  string    `gorm:"not null;" json:"ext"`
	Size int64     `gorm:"not null;" json:"size"`
	Data []byte    `gorm:"not null" json:"-"`
	Time time.Time `gorm:"not null" json:"time,omitempty"`
}

func SaveLocalFile

func SaveLocalFile(xfs XFS, id string, filename string) (*File, error)

func SaveUploadedFile

func SaveUploadedFile(xfs XFS, id string, file *multipart.FileHeader) (*File, error)

type FileResult

type FileResult struct {
	File *File `json:"file"`
}

type FilesResult

type FilesResult struct {
	Files []*File `json:"files"`
}

type XFS

type XFS interface {
	fs.FS

	SaveFile(id string, filename string, data []byte, modTime ...time.Time) (*File, error)
	ReadFile(fid string) ([]byte, error)
	DeleteFile(id string) error
	DeleteFiles(ids ...string) (int64, error)
	DeletePrefix(prefix string) (int64, error)
	DeleteBefore(before time.Time) (int64, error)
	DeleteWhere(where string, args ...any) (int64, error)
	DeleteAll() (int64, error)
	Truncate() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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