go - golan-gin api 返回无效的 URL 转义 %
问题描述
我想创建一个用于在我的 go-gin 应用程序中上传图像的 api。这是我当前的 api 代码:
func (s *Service) ImageCreate(c *gin.Context) {
token := c.MustGet(tokenKey).(*models.Token)
now := time.Now()
file, err := c.FormFile("file")
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "01> " + err.Error()})
return
}
}
当我从浏览器调用我的应用程序时,它返回此错误:
{"error":"01\u003e invalid URL escape \"%$\\xf4\""}
在邮递员 api 中,它可以正常工作。怎么了?如何为浏览器修复它?
解决方案
不要使用邮递员。
curl -X POST http://localhost:8080/server-image/upload-file -F "file=@/Users/shikuanxu/Downloads/images/course-outline.png" -H "Content-Type: multipart/form-data"
再试一次
推荐阅读
- python - 我如何遍历列(类型:系列)
- postgresql - 我应该使用 JSONB 还是 JOIN 表来记录 PostgreSQL 中的用户操作和注释?
- java - 使用 pache poi 4.1.0 给出多个错误
- linux - 我可以在运行时限制我在 CGI 脚本中允许进入的文件夹吗?
- vba - 在 VBA 中出现“无效的过程调用或参数”错误
- html - 将内联样式转换为包含属性的标签
- python - 如何修改seaborn小提琴情节图例
- java - %1 不是有效的 Win32 应用程序
- caldav - CalDAV 收件人接受的预期行为是什么?
- c# - 如何找到 SQL Server 中两列之间的差异?