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

Bind file from multipart/form-data request #2672

Closed
3 tasks done
MilkeeyCat opened this issue Aug 9, 2024 · 3 comments
Closed
3 tasks done

Bind file from multipart/form-data request #2672

MilkeeyCat opened this issue Aug 9, 2024 · 3 comments

Comments

@MilkeeyCat
Copy link

Issue Description

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Hi :D. Is there a way to bind file from multipart/form-data request to a struct field? For example

type Data struct {
	File multipart.FileHeader `form:"file"`
}
@aldas
Copy link
Contributor

aldas commented Aug 9, 2024

no at the moment. Could you provide small example for posting data in that way (for example with curl) and I can think if there are some ways to do this.

Currently we delegate all form binding/parsing logic to standard library when it comes to form data. See

echo/bind.go

Line 93 in f13e264

case strings.HasPrefix(ctype, MIMEApplicationForm), strings.HasPrefix(ctype, MIMEMultipartForm):

@MilkeeyCat
Copy link
Author

curl -v http://localhost:8080 -F '[email protected]'

there should also be a file called image.png in the directory you execute the command or you can change the file path

@aldas
Copy link
Contributor

aldas commented Oct 20, 2024

implemented by @martinyonatann in #2684

@aldas aldas closed this as completed Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants