feat(admin) add multipart/form-data support to admin api (80% solution) #3776
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
:lua-resty-upload
to stream readmultipart/form-data
upload.lua-resty-upload
consumes the request body without writing it back, which means that you cannot read request body in ourarguments
parser.multipart/form-data
params in admin api is through Lapisself.req.params_post
.multipart/form-data
to a key/value table. And because of that you cannot send same name inmultipart/form-data
twice, e.g.paths=/first
andpaths=/second
ORpaths[]=/first
andpaths[]=/second
. But you can work-around that on client side by sending:paths[1]=/first
andpaths[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.