Kratos中使用gin处理excel文件上传
功能概述
在kratos框架中使用gin处理http请求,实现上传固定格式的excel文件并将excel中的数据存入MySQL数据库与Redis中。
项目地址
https://gitee.com/huoyingwhw/kratos-gin
需要注意的点
使用postman测试文件上传注意
1、设置Content-Type,boundary参数见下面参考文章中的介绍:

2、body中使用form-data上传文件,并且key用“file”,因为项目中使用的方法用“file”这个key获取文件的:

批量写入数据库时注意控制下一次写入的数量

这里设置的BatchCreateUserSize是,如果列表中有5个用户的话,每次只会写入2条数据,直到写完为止:

~~~
参考资料
kratos中使用gin
postman请求文件上传遇到的问题
【http/https】Content-Type的boundary
robotframework调用上传文件接口报错“the request was rejected because no multipart boundary was found”
~~~