douju4594 2019-02-13 20:19 采纳率: 100%
浏览 556

golan-gin api返回无效的URL转义%

I want to create an api for uploading images in my go-gin application. This is my current api code :

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

When I call my application from the browser it returns this error:

{"error":"01\u003e invalid URL escape \"%$\\xf4\""}

In postman api it's working without error. What is wrong? How I can fix it for the browser?

  • 写回答

1条回答 默认 最新

  • dongpiao9078 2019-03-13 08:23
    关注

    Don't use Postman.

    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"
    

    Try again

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!