package file import ( "github.com/gin-gonic/gin" ) const fieldName = "file" const PathDeep = 2 const PathLen = 2 const SavePath = "./data/file/" const UrlPrefix = "http://" var imageMimes map[string]struct{} const pathPrefix = "file" func Handler(r *gin.Engine) { // set memory limit r.MaxMultipartMemory = 8 << 20 // 8MB group := r.Group(pathPrefix) group.POST("upload-image", UploadImage) group.POST("upload", Upload) } func init() { imageMimes = map[string]struct{}{ "image/png": struct{}{}, "image/jpeg": struct{}{}, "image/gif": struct{}{}, } }