filemanager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BrowseHandler

func BrowseHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

BrowseHandler finds a glob of files in directory and returns as JSON output

func DeleteHandler

func DeleteHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

DeleteHandler accepts array of paths and delete them on disk

func DownloadHandler

func DownloadHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

DownloadHandler reads a file and send it contents to response writer

func GetFileName

func GetFileName(path string) string

GetFileName returns filename from path

func Init

func Init(rootDir string)

Init initializes file manager.

func UploadHandler

func UploadHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

UploadHandler reads a file from HTTP request and save it to disk

Types

type FileInfo

type FileInfo struct {
	Filename string   `json:"filename"`
	Filepath string   `json:"filepath"`
	Dirpath  string   `json:"dirpath"`
	Ext      string   `json:"ext"`
	Mime     string   `json:"mime"`
	Stat     FileStat `json:"stat"`
}

FileInfo structure holds data of file

func GetFileInfo

func GetFileInfo(path string) (FileInfo, error)

GetFileInfo returns info of the file or error if occurs

type FileStat

type FileStat struct {
	IsDir   bool        `json:"isdir"`
	Mode    os.FileMode `json:"mode"`
	ModTime time.Time   `json:"modtime"`
	Name    string      `json:"name"`
	Size    int64       `json:"size"`
}

FileStat structure holds stat data of a file

type JSONDeleteRequest

type JSONDeleteRequest struct {
	Paths []string `json:"paths"`
}

JSONDeleteRequest holds data structure for delete post request

type JSONResponse

type JSONResponse struct {
	Status int         `json:"status"`
	Data   interface{} `json:"data"`
}

JSONResponse holds data structure for responses

Jump to

Keyboard shortcuts

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