当前位置:网站首页>go gin : 多文件上传
go gin : 多文件上传
2022-07-22 22:47:00 【IT工作者】
本文实验,gin框架下的多文件上传
func main() {
router := gin.Default()
// Set a lower memory limit for multipart forms (default is 32 MiB)
// router.MaxMultipartMemory = 8 << 20 // 8 MiB
router.POST("/upload", func(c *gin.Context) {
// Multipart form
form, _ := c.MultipartForm()
files := form.File["upload[]"]
for _, file := range files {
log.Println(file.Filename)
// Upload the file to specific dst.
// c.SaveUploadedFile(file, dst)
}
c.String(http.StatusOK, fmt.Sprintf("%d files uploaded!", len(files)))
})
router.Run(":8080")
}运行服务端代码
客户端测试访问
curl -X POST http://localhost:8080/upload \
-F "upload[][email protected]/Users/huahua/gopath/src/gintest/html/bar.tmpl" \
-H "Content-Type: multipart/form-data"
1 files uploaded!服务端日志
边栏推荐
猜你喜欢

获取一个控件宽度

Live broadcast preview | live broadcast Seminar on open source security governance models and tools

读书笔记->统计学】12-02 置信区间的构建-t分布概念简介

Cloud computing may become a new inflection point in the era? From which point can we see?

Internet traffic scheduling scheme

Come on, slide to the next little sister

JMeter distributed pressure measurement

论文阅读:The Perfect Match: 3D Point Cloud Matching with Smoothed Densities

将childNodes返回的伪数组转化为真数组

Easily take you to the gate of turtle drawing
随机推荐
Qgraicsview implementation palette
Google Earth engine app - a complete map legend app (land use classification of western United States)
Binary tree (learning daily)
This is not a true sense of the meta universe, which should have its own distinctive characteristics and unique development logic
synchronized是如何实现的
Jmeter分布式压测
挖财和启牛都是干什么的开户安全吗?
How to implement WebService service on the c/s side of C #
WPS data splitting
Flynk uses liststate to implement keyedstate
Object prototype of typescript object extension__ proto__ And prototype
Flink advanced API (III)
Redis 事务学习有感
阿里云国际版注册成功后添加支付方式
JMeter distributed pressure measurement
C语言中的字符串
Networkx visualizes graphs
Data types in redis
C语言函数(1)
Genesis公链:夯实Web 3.0发展底座