Documentation ¶
Index ¶
- func Dump() (allFiles map[int64]io.ReadCloser, err error)
- func FileStat(filename string) (os.FileInfo, error)
- func GetTables() []interface{}
- func InitFileHandler()
- func InitTestFileFixtures(t *testing.T)
- func InitTestFileHandler()
- func InitTests()
- func IsErrFileDoesNotExist(err error) bool
- func IsErrFileIsNotUnsplashFile(err error) bool
- func IsErrFileIsTooLarge(err error) bool
- func SetEngine() (err error)
- type ErrFileDoesNotExist
- type ErrFileIsNotUnsplashFile
- type ErrFileIsTooLarge
- type File
- func Create(f io.Reader, realname string, realsize uint64, a web.Auth) (file *File, err error)
- func CreateWithMime(f io.Reader, realname string, realsize uint64, a web.Auth, mime string) (file *File, err error)
- func CreateWithMimeAndSession(s *xorm.Session, f io.Reader, realname string, realsize uint64, a web.Auth, ...) (file *File, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dump ¶ added in v0.14.0
func Dump() (allFiles map[int64]io.ReadCloser, err error)
Dump dumps all saved files This only includes the raw files, no db entries.
func FileStat ¶
FileStat stats a file. This is an exported function to be able to test this from outide of the package
func GetTables ¶
func GetTables() []interface{}
GetTables returns all structs which are also a table.
func InitFileHandler ¶
func InitFileHandler()
InitFileHandler creates a new file handler for the file backend we want to use
func InitTestFileFixtures ¶
InitTestFileFixtures initializes file fixtures
func InitTestFileHandler ¶
func InitTestFileHandler()
InitTestFileHandler initializes a new memory file system for testing
func IsErrFileDoesNotExist ¶
IsErrFileDoesNotExist checks if an error is ErrFileDoesNotExist
func IsErrFileIsNotUnsplashFile ¶ added in v0.14.0
IsErrFileIsNotUnsplashFile checks if an error is ErrFileIsNotUnsplashFile
func IsErrFileIsTooLarge ¶
IsErrFileIsTooLarge checks if an error is ErrFileIsTooLarge
Types ¶
type ErrFileDoesNotExist ¶
type ErrFileDoesNotExist struct {
FileID int64
}
ErrFileDoesNotExist defines an error where a file does not exist in the db
func (ErrFileDoesNotExist) Error ¶
func (err ErrFileDoesNotExist) Error() string
Error is the error implementation of ErrFileDoesNotExist
type ErrFileIsNotUnsplashFile ¶ added in v0.14.0
type ErrFileIsNotUnsplashFile struct {
FileID int64
}
ErrFileIsNotUnsplashFile defines an error where a file is not downloaded from unsplash. Used in cases whenever unsplash information about a file is requested, but the file was not downloaded from unsplash.
func (ErrFileIsNotUnsplashFile) Error ¶ added in v0.14.0
func (err ErrFileIsNotUnsplashFile) Error() string
Error is the error implementation of ErrFileIsNotUnsplashFile
type ErrFileIsTooLarge ¶
type ErrFileIsTooLarge struct {
Size uint64
}
ErrFileIsTooLarge defines an error where a file is larger than the configured limit
func (ErrFileIsTooLarge) Error ¶
func (err ErrFileIsTooLarge) Error() string
Error is the error implementation of ErrFileIsTooLarge
type File ¶
type File struct { ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"` Name string `xorm:"text not null" json:"name"` Mime string `xorm:"text null" json:"mime"` Size uint64 `xorm:"bigint not null" json:"size"` Created time.Time `xorm:"created" json:"created"` CreatedByID int64 `xorm:"bigint not null" json:"-"` File afero.File `xorm:"-" json:"-"` // This ReadCloser is only used for migration purposes. Use with care! // There is currentlc no better way of doing this. FileContent []byte `xorm:"-" json:"-"` }
File holds all information about a file
func CreateWithMime ¶ added in v0.15.0
func CreateWithMime(f io.Reader, realname string, realsize uint64, a web.Auth, mime string) (file *File, err error)
CreateWithMime creates a new file from an FileHeader and sets its mime type
func CreateWithMimeAndSession ¶ added in v0.18.0
func (*File) LoadFileByID ¶
LoadFileByID returns a file by its ID
func (*File) LoadFileMetaByID ¶
LoadFileMetaByID loads everything about a file without loading the actual file