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

Can not handle multipart/form-data #637

Closed
radovans opened this issue Nov 13, 2019 · 8 comments · Fixed by #639
Closed

Can not handle multipart/form-data #637

radovans opened this issue Nov 13, 2019 · 8 comments · Fixed by #639
Labels

Comments

@radovans
Copy link

Hello, I have problem with logbook. When I create endpoint where I am able to upload the file everything works correctly. After adding logbook dependency I am not able to work with the uploaded file.

Steps to Reproduce

For better understanding I have created minimal example with bug: https://github.com/radovans/logbook-problem

when I call the endpoint with postman:
curl -X POST \ http://localhost:8888/upload/file \ -H 'Accept: */*' \ -H 'Accept-Encoding: gzip, deflate' \ -H 'Connection: keep-alive' \ -H 'Content-Length: 15001' \ -H 'Content-Type: multipart/form-data; boundary=--------------------------606195755734019197267982' \ -H 'Host: localhost:8888' \ -H 'User-Agent: PostmanRuntime/7.19.0' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F file=@resume.pdf

postman

I get error

{ "timestamp": "2019-11-13T14:23:42.887+0000", "status": 400, "error": "Bad Request", "message": "Required request part 'file' is not present", "path": "/upload/file" }

so I am not able to handle the file and store it for example. When i remove all logbook dependencies I have no problem with that.

@radovans radovans added the Bug label Nov 13, 2019
@whiskeysierra
Copy link
Collaborator

How did you configure logbook? multipart/* bodies are skipped by default.

@radovans
Copy link
Author

radovans commented Nov 13, 2019

@Bean public Logbook logbook() { return Logbook.builder().build(); }

You can reproduce it easily with attached project.

I can see request logged by logbook

2019-11-13 15:23:42.854 TRACE 39988 --- [nio-8888-exec-4] org.zalando.logbook.Logbook : Incoming Request: c3dbfb1898066a6c
Remote: 0:0:0:0:0:0:0:1
POST http://localhost:8888/upload/file HTTP/1.1
accept: /
accept-encoding: gzip, deflate
connection: keep-alive
content-length: 15001
content-type: multipart/form-data; boundary=--------------------------606195755734019197267982
host: localhost:8888
user-agent: PostmanRuntime/7.19.0
multipart

but i can not work with the uploaded file itself and got error above.

Rest controller: https://github.com/radovans/logbook-problem/blob/master/src/main/java/com/test/demo/Controller.java
Logbook version: 2.0.0-RC.5
Spring Boot version: 2.2.1.RELEASE

@whiskeysierra
Copy link
Collaborator

Found the issue. I'm working on a fix.

@cmohankumar
Copy link

Hello is this issue resolved? i am having same issue and i am using the same logbook library version. pls let me know how to resolve the error.

@whiskeysierra
Copy link
Collaborator

You say you're using the same version. Do you mean the latest?

@cmohankumar
Copy link

@whiskeysierra -
Spring boot version: 2.4.10
Zalando logbook : 2.0.0 RC3

I am facing same error as described by OP.
Pls assist

@whiskeysierra
Copy link
Collaborator

Zalando logbook : 2.0.0 RC3

That version is even older than the one this issue was originally opened for.
Obviously, the fix is only available in newer versions.
Why are you using such an old version to begin with?

@cmohankumar
Copy link

The project I work is a maintenance application. Can you recommend the version that we shall use to get over this issue .. we are using spring boot v2.4.10 which we can’t upgrade further.. but logbook we can.

pls suggest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants