Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(path string)

Delete the file at the given path.

To avoid panics, you should check if the file exists.

func FileExists

func FileExists(file string) bool

FileExists returns true if the file at the given path exists and is readable. Returns false if the given file is a directory.

func GetFileExtension

func GetFileExtension(file string) string

GetFileExtension returns the last part of a file name. If the file doesn't have an extension, returns an empty string.

func GetMIMEType

func GetMIMEType(file string) (string, int64)

GetMIMEType get the mime type and size of the given file.

If the file cannot be opened, panics. You should check if the file exists, using "filesystem.FileExists()"", before calling this function.

func IsDirectory

func IsDirectory(path string) bool

IsDirectory returns true if the file at the given path exists, is a directory and is readable.

Types

type File

type File struct {
	Header   *multipart.FileHeader
	MIMEType string
	Data     multipart.File
}

File represents a file received from client.

func ParseMultipartFiles

func ParseMultipartFiles(request *http.Request, field string) []File

ParseMultipartFiles parse a single file field in a request.

func (*File) Save

func (file *File) Save(path string, name string) string

Save writes the given file on the disk. Appends a timestamp to the given file name to avoid duplicate file names. The file is not readable anymore once saved as its FileReader has already been closed.

Creates directories if needed.

Returns the actual file name.