web

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package web provides helpers to work with website.

Index

Constants

This section is empty.

Variables

View Source
var (
	AllowedFileTypes  []string
	MaxUploadFileSize int
)

Functions

func DownloadStaticFile

func DownloadStaticFile(w http.ResponseWriter, r *http.Request, filePath, fileName, newFileName string)

DownloadStaticFile downloads a file, and force the browser to avoid displaying it in the browser window by setting content disposition. It also allows specification of the display name.

Types

type UploadedFile

type UploadedFile struct {
	FileSize         int64
	NewFileName      string
	OriginalFileName string
}

UploadedFile is a struct used to save information about an uploaded file.

func UploadFile

func UploadFile(r *http.Request, uploadDir string, rename ...bool) (*UploadedFile, error)

UploadFile uploads one file to the specified directory with random file name. If rename is true, then original file name is use.

func UploadFiles

func UploadFiles(r *http.Request, uploadDir string, rename ...bool) ([]*UploadedFile, error)

UploadFiles uploads one or more files to the specified directory with random file names. If rename is true, then original file names are use.

Jump to

Keyboard shortcuts

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