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

feat(admin) add multipart/form-data support to admin api (80% solution) #3776

Merged
merged 1 commit into from Sep 17, 2018

Conversation

bungle
Copy link
Member

@bungle bungle commented Sep 15, 2018

Summary

This adds multipart/form-data support to Admin API. But this is not a 100% solution as there turns our to be edge cases because of Lapis Framework that are not very easy to solve without rather complex changes.

How Lapis Reads the multipart/form-data:

  1. On OpenResty Lapis uses lua-resty-upload to stream read multipart/form-data upload.
  2. lua-resty-upload consumes the request body without writing it back, which means that you cannot read request body in our arguments parser.
  3. That means that only place we can access multipart/form-data params in admin api is through Lapis self.req.params_post.
  4. Lapis in turn does parsing of multipart/form-data to a key/value table. And because of that you cannot send same name in multipart/form-data twice, e.g. paths=/first and paths=/second OR paths[]=/first and paths[]=/second. But you can work-around that on client side by sending: paths[1]=/first and paths[2]=/second. That's why I call this 80% solution.

Should we wait for 100% solution? In my opinion not. This 80% solution is already more than enough to solve issues such as:
#3738
#3610

We can re-visit this later with 100% solution.

kikito
kikito previously requested changes Sep 17, 2018
Copy link
Member

@kikito kikito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I think this needs one or two tests before we can merge it.

@bungle
Copy link
Member Author

bungle commented Sep 17, 2018

@kikito I added multipart/form-data to many it_content_types tests, but because issues in client, and because of this 80% solution, I needed to skip it in some tests. But in general this adds a lot of tests there.

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

Successfully merging this pull request may close these issues.

None yet

3 participants