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

Named request body field from file? #722

Open
abimdanu opened this issue Mar 27, 2025 · 2 comments
Open

Named request body field from file? #722

abimdanu opened this issue Mar 27, 2025 · 2 comments

Comments

@abimdanu
Copy link

I need to send an image data (multipart/form-data) in the request body, but it has to be inside the field "image". How to achieve this?

Help would be much appreciated.

@abimdanu abimdanu changed the title Named request body from file? Named request body field from file? Mar 27, 2025
@hatoo
Copy link
Owner

hatoo commented Mar 27, 2025

You need to prepare a body file for multipart/form-data.

I think we can do it by these steps.

Create body.txt. The boundary ---------------------------9051914041544843365972754766 is arbitrary.

---------------------------9051914041544843365972754766
Content-Disposition: form-data; name="image"; filename="example.jpg"
Content-Type: image/jpeg


cat body.txt example.jpg > body
oha -H "Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754766" -D ./body

@jperezr21
Copy link

Would be nice to have a -F "file=@/path/to/your/file.jpg" flag like cURL has

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

3 participants