adsa-cms: github.com/mmanjoura/adsa-cms/filebox Index | Files

package filebox

import "github.com/mmanjoura/adsa-cms/filebox"

Index

Package Files

controller.go filebox.go

type Dir Uses

type Dir struct {
    DirPath string
    Roles   []string
    Filebox *Filebox
}

Dir is a object to access a specific directory

func (*Dir) HasPermission Uses

func (dir *Dir) HasPermission(mode roles.PermissionMode) bool

HasPermission used to check current user whether have permission to access directory

func (*Dir) SetPermission Uses

func (dir *Dir) SetPermission(permission *roles.Permission) (err error)

SetPermission used to set a Permission to directory

func (*Dir) WriteFile Uses

func (dir *Dir) WriteFile(fileName string, reader io.Reader) (file *File, err error)

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile will create a new file

type File Uses

type File struct {
    FilePath string
    Roles    []string
    Dir      *Dir
    Filebox  *Filebox
}

File is a object to access a specific file

func (*File) HasPermission Uses

func (f *File) HasPermission(mode roles.PermissionMode) bool

HasPermission used to check current user whether have permission to access file

func (*File) Read Uses

func (f *File) Read() (io.ReadSeeker, error)

Read will get a io reader for a specific file

func (*File) SetPermission Uses

func (f *File) SetPermission(permission *roles.Permission) (err error)

SetPermission used to set a Permission to file

func (*File) Write Uses

func (f *File) Write(reader io.Reader) (err error)

Write used to store reader's content to a file

type Filebox Uses

type Filebox struct {
    BaseDir string
    Auth    admin.Auth
    // contains filtered or unexported fields
}

Filebox is a based object contains download folder path and admin.Auth used to get current user

func New Uses

func New(dir string) *Filebox

New a filebox struct

func (*Filebox) AccessDir Uses

func (filebox *Filebox) AccessDir(dirPath string, roles ...string) *Dir

AccessDir will return a specific Dir object

func (*Filebox) AccessFile Uses

func (filebox *Filebox) AccessFile(filePath string, roles ...string) *File

AccessFile will return a specific File object

func (*Filebox) Download Uses

func (filebox *Filebox) Download(w http.ResponseWriter, req *http.Request)

Download is a handler will return a specific file

func (*Filebox) MountTo Uses

func (filebox *Filebox) MountTo(mountTo string, mux *http.ServeMux)

MountTo will mount to mux to route `mountto`

func (*Filebox) ServeHTTP Uses

func (filebox *Filebox) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is a implement for http server interface

func (*Filebox) SetAuth Uses

func (filebox *Filebox) SetAuth(auth admin.Auth)

SetAuth will set a admin.Auth struct to Filebox, used to get current user's role

Package filebox imports 12 packages (graph) and is imported by 1 packages. Updated 2017-06-20. Refresh now. Tools for package owners.