We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello there!
I'm trying to figure out if there's a way to simplify an upload handler by including the form file in with the bind object.
type UploadRequest struct { Image interface{} `form:"image" binding:"required"` Description string `form:"description" binding:"required"` Owner string `form:"owner" binding:"required"` } func HandleUpload(c *gin.Context) { req := new(UploadRequest) if err := c.ShouldBind(req); err != nil { // fail brilliantly } // do wonderful upload-y type things }
However, when CURLing an image up I receive a binding error:
$ curl -F 'description=super cool thing' -F 'owner=rbalboa27' -F 'image=@/path/to/image.iso' http://localhost:8000/api/image/v1.0/upload bailing: Key: 'UploadRequest.Image' Error:Field validation for 'Image' failed on the 'required' tag
I've tried a few variations to try and "sniff" the type of UploadRequest.Image to no avail.
Is this type of thing supported/a feature within Gin?
The text was updated successfully, but these errors were encountered:
Maybe #1264
Sorry, something went wrong.
@thinkerou I'll close this and follow #1264. thanks!
No branches or pull requests
Hello there!
I'm trying to figure out if there's a way to simplify an upload handler by including the form file in with the bind object.
However, when CURLing an image up I receive a binding error:
I've tried a few variations to try and "sniff" the type of UploadRequest.Image to no avail.
Is this type of thing supported/a feature within Gin?
The text was updated successfully, but these errors were encountered: