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 1 commit into from Sep 17, 2018


None yet
3 participants
Copy link

bungle commented Sep 15, 2018


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:

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

@bungle bungle force-pushed the feat/admin-multipart branch from 857fbc7 to b566165 Sep 16, 2018

Copy link

kikito left a comment

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

@bungle bungle force-pushed the feat/admin-multipart branch from b566165 to 6aca9ff Sep 17, 2018


This comment has been minimized.

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.


@bungle bungle merged commit a1c2001 into next Sep 17, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@bungle bungle deleted the feat/admin-multipart branch Sep 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.