You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
573 B

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{}{},
}
}