xfs

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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:255;not null;primaryKey" json:"id"`
	Name string    `gorm:"not null;" json:"name"`
	Ext  string    `gorm:"not null;" json:"ext"`
	Tag  string    `gorm:"not null;default:'';index:idx_files_tag" json:"tag"`
	Time time.Time `gorm:"not null" json:"time"`
	Size int64     `gorm:"not null;" json:"size"`
	Data []byte    `gorm:"not null" json:"-"`
}

func SaveLocalFile

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

func SaveUploadedFile

func SaveUploadedFile(xfs XFS, id string, file *multipart.FileHeader, tag ...string) (*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.ReadFileFS

	// FindFile find a file
	FindFile(id string) (*File, error)

	// SaveFile save a file
	SaveFile(id string, filename string, filetime time.Time, data []byte, tag ...string) (*File, error)

	// CopyFile copy file `src` to `dst`
	CopyFile(src, dst string, tag ...string) error

	// MoveFile move file `src` to `dst`
	MoveFile(src, dst string, tag ...string) error

	// DeleteFile delete file by id
	DeleteFile(id string) error

	// DeleteFiles delete file by ids
	DeleteFiles(ids ...string) (int64, error)

	// DeletePrefix delete files by prefix
	DeletePrefix(prefix string) (int64, error)

	// DeleteTagged delete files by tag
	DeleteTagged(tag string) (int64, error)

	// DeleteBefore delete files by time
	DeleteBefore(before time.Time) (int64, error)

	// DeletePrefixBefore delete files by prefix and time
	DeletePrefixBefore(prefix string, before time.Time) (int64, error)

	// DeleteTaggedBefore delete files by tag and time
	DeleteTaggedBefore(tag string, before time.Time) (int64, error)

	// DeleteWhere delete files by customized where filter
	DeleteWhere(where string, args ...any) (int64, error)

	// DeleteAll delete all files
	DeleteAll() (int64, error)

	// Truncate truncate files
	Truncate() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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