Documentation ¶
Index ¶
- func CheckPasswordHash(password, hash string) bool
- func GenerateRandomBytes(n int) ([]byte, error)
- func HashPassword(password string) (string, error)
- func ResolveContextUser(c *Context) (p, previewPath, urlPath string, err error)
- type Context
- func (c *Context) CutPath(path string) string
- func (c *Context) GenPreview(out string)
- func (c *Context) GenSharesPreview(out string)
- func (c *Context) GetAuthConfig() *config.ListenConf
- func (c *Context) GetUserHomePath() string
- func (c *Context) GetUserPreviewPath() string
- func (c *Context) GetUserSharesPath() string
- func (c *Context) IsExternalShare() (r bool)
- type FSBuilder
- type File
- type FileBrowser
- type FileSystem
- type FitFilter
- type Listing
- type Params
- type ReCaptcha
- type UserModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash compares a password with an hash to check if they match.
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an fm.Error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func HashPassword ¶
HashPassword generates an hash from a password using bcrypt.
func ResolveContextUser ¶ added in v0.8.6
build correct path, and replace user in context in case external share
Types ¶
type Context ¶
type Context struct { *FileBrowser User *UserModel File *File // On API handlers, Router is the APi handler we want. Router int *Params FitFilter }
Context contains the needed information to make handlers work.
func (*Context) GenPreview ¶
func (*Context) GenSharesPreview ¶ added in v0.8.3
func (*Context) GetAuthConfig ¶ added in v0.8.3
func (c *Context) GetAuthConfig() *config.ListenConf
func (*Context) GetUserHomePath ¶ added in v0.1.8
func (*Context) GetUserPreviewPath ¶ added in v0.1.8
func (*Context) GetUserSharesPath ¶ added in v0.8.3
func (*Context) IsExternalShare ¶ added in v0.8.3
true if request contains rootHash param
type File ¶
type File struct { // Indicates the Kind of view on the front-end (Listing, editor or preview). Kind string `json:"kind"` // The name of the file. Name string `json:"name"` // The Size of the file. Size int64 `json:"size"` // The absolute URL. URL string `json:"url"` // The extension of the file. //Extension string `json:"extension"` // The last modified time. ModTime time.Time `json:"modified"` // The File Mode. //Mode os.FileMode `json:"mode"` // Indicates if this file is a directory. IsDir bool `json:"isDir"` // Absolute path. Path string `json:"-"` // Relative path to user's virtual File System. VirtualPath string `json:"-"` // Indicates the file content type: video, text, image, music or blob. Type string `json:"type"` // Stores the content of a text file. Content string `json:"content,omitempty"` Checksums map[string]string `json:"checksums,omitempty"` *Listing `json:",omitempty"` Language string `json:"language,omitempty"` }
File contains the information about a particular file or directory.
func (File) CanBeEdited ¶
CanBeEdited checks if the extension of a file is supported by the editor
func (*File) GetListing ¶
recursively fetch share/file paths
func (*File) ProcessList ¶ added in v0.8.5
ProcessList generate metainfo about dir/files
func (*File) SetFileType ¶
SetFileType obtains the mimetype and converts it to a simple type nomenclature.
type FileBrowser ¶
type FileBrowser struct { // The static assets. Assets *rice.Box // ReCaptcha host, key and secret. ReCaptcha *ReCaptcha // NewFS should build a new file system for a given path. NewFS FSBuilder //generates preview Pgen *preview.PreviewGen Config *config.GlobalConfig }
FileBrowser is a file manager instance. It should be creating using the 'New' function and not directly.
func (*FileBrowser) Setup ¶
func (fb *FileBrowser) Setup() (bool, error)
Setup loads the configuration from the database and configures the Assets and the Cron job. It must always be run after creating a File Browser object.
type FileSystem ¶
type FileSystem interface { Mkdir(name string, perm os.FileMode, uid, gid int) error OpenFile(name string, flag int, perm os.FileMode, uid, gid int) (*os.File, error) RemoveAll(name string) error Rename(oldName, newName string) error Stat(name string) (os.FileInfo, error) Copy(src, dst string, uid, gid int) error String() string }
FileSystem is the interface to work with the file system.
type Listing ¶
type Listing struct { // The items (files and folders) in the path. Items []*File `json:"items"` // The number of directories in the Listing. NumDirs int `json:"numDirs"` // The number of files (items that aren't directories) in the Listing. NumFiles int `json:"numFiles"` // Which sorting order is used. Sort string `json:"sort"` // And which order. Order string `json:"order"` //indicator to the frontend, to prevent request previews AllowGeneratePreview bool `json:"allowGeneratePreview"` }
A Listing is the context used to fill out a template.
type Params ¶ added in v0.8.3
type Params struct { //indicate that requested preview PreviewType string //return files list by recursion IsRecursive bool //indicate about share request, nformation about share metadata like list, my-meta. SearchString string /* external share item root dir hash, note: as a result, cut owner from files paths, and replaces with rootHash(hash value of specific shareItem) */ RootHash string //download type, zip or playlist m3u8 Algo string //download multiple files FilePaths []string Auth string Checksum string Inline bool // playlist & search file mime types, true if any was specified at request url, uses in FitFilter type Audio bool Image bool Video bool Pdf bool //search query Query url.Values //override existing file Override bool // used in resource patch requests type Destination string Action string Sort string Order string IsShare bool //requestURL URL string Method string RESP http.ResponseWriter REQ *http.Request }
params in URL request
type UserModel ¶
type UserModel struct { *config.UserConfig ID string `json:"ID"` // FileSystem is the virtual file system the user has access. FileSystem FileSystem `json:"-"` // FileSystem is the virtual file system the user has access, uses to store previews. FileSystemPreview FileSystem `json:"-"` }
func ToUserModel ¶ added in v0.1.8
func ToUserModel(u *config.UserConfig, cfg *config.GlobalConfig) *UserModel