Skip to content
New issue

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

Binding issue with multipart form and files uplaod #1263

Closed
p581581 opened this issue Mar 1, 2018 · 1 comment
Closed

Binding issue with multipart form and files uplaod #1263

p581581 opened this issue Mar 1, 2018 · 1 comment
Labels

Comments

@p581581
Copy link
Contributor

p581581 commented Mar 1, 2018

Hi,

I'm currently using go v1.9.2 and gin v1.2. Is there any way to bind file data with form and check if it is exist. Or, form's file can only be retrieved by c.fromfile()

Here is the form struct:

// Binding from Form
type PhoptUploadForm struct {
	imgData    *multipart.FileHeader `form:"img_data" binding:"required"`
	ProjectID   string `form:"project_id" binding:"required"`
	Description string `form:"description binding:"required"`
}

and the request body:

------WebKitFormBoundarysOtthv5MjO3ut9Ao
Content-Disposition: form-data; name="img_data"; filename="blob"
Content-Type: image/jpeg


------WebKitFormBoundarysOtthv5MjO3ut9Ao
Content-Disposition: form-data; name="project_id"

263a5c1d-c8f8-4bf2-9bc5-e70982820a96
------WebKitFormBoundarysOtthv5MjO3ut9Ao
Content-Disposition: form-data; name="description"

description-test
------WebKitFormBoundarysOtthv5MjO3ut9Ao

appleboy pushed a commit that referenced this issue Mar 18, 2019
update for supporting multipart form and file binding 

example:
```
type PhoptUploadForm struct {
	imgData    *multipart.FileHeader `form:"img_data" binding:"required"`
	ProjectID   string `form:"project_id" binding:"required"`
	Description string `form:"description binding:"required"`
}
```


ref: #1263
@thinkerou
Copy link
Member

#1264 merged! thanks!

dnephin pushed a commit to dnephin/gin-binding-tmp that referenced this issue Jan 13, 2023
update for supporting multipart form and file binding 

example:
```
type PhoptUploadForm struct {
	imgData    *multipart.FileHeader `form:"img_data" binding:"required"`
	ProjectID   string `form:"project_id" binding:"required"`
	Description string `form:"description binding:"required"`
}
```


ref: gin-gonic/gin#1263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants