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 ¶
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 ¶
GetFileExtension returns the last part of a file name. If the file doesn't have an extension, returns an empty string.
func GetMIMEType ¶
GetMIMEType get the mime type and size of the given file. This function calls `http.DetectContentType`. If the detected content type could not be determined or if it's a text file, `GetMIMEType` will attempt to detect the MIME type based on the file extension. The following extensions are supported:
- `.jsonld`: "application/ld+json"
- `.json`: "application/json"
- `.js` / `.mjs`: "text/javascript"
- `.css`: "text/css"
If a specific MIME type cannot be determined, returns "application/octet-stream" as a fallback.
func IsDirectory ¶
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 }
File represents a file received from client.
func ParseMultipartFiles ¶
func ParseMultipartFiles(headers []*multipart.FileHeader) ([]File, error)
ParseMultipartFiles parse a single file field in a request.