-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Improve file upload in new platform route handlers #56944
Comments
Pinging @elastic/kibana-platform (Team:Platform) |
We need to do something here since Hapi interface shouldn't leak outside. We can handle My only concern with the current implementation that it stores parsed content in the memory. From Hapi typings for payload.output:
If the necessity to access the filename the only reason for that, we could change our API not to use FormData (we send the single file anyway) and to pass filename via headers. |
Also that would mean breaking changes in the SO import/export API, even if this API is 'experimental'.
We can do that. It feels like reinventing the wheel a little though, as our underlying http framework already handles it for us. If the
Not sure to see any other option to use payload content during request's lifecycle without asking the handler to do the parsing itself, which sounds like poor developer experience to me? |
Yes, we can keep using
I think adding a wrapper around hapi parsed file is the simplest option at the moment.
|
How do we handle routes with additional payload values without multipart though? We will be sending a json body payload with the 'binary' content of the file in a field? kibana/src/core/server/saved_objects/routes/resolve_import_errors.ts Lines 44 to 69 in 055c611
|
File upload is something we overlooked regarding route handler features.
A concrete example on how to handle file upload in legacy:
kibana/src/legacy/server/saved_objects/routes/import.ts
Lines 50 to 91 in 3e8687c
object
to define the fileatm, the file is a readable stream enhanced by some HAPI wrapper to add additional data such as filename
then when accessing the properties:
Questions
schema.file()
and/or aschema.stream()
request.payload.file.hapi.filename
)? That sounds a little tricky/fragile as we will need to look at the hapi parsed payload/body to convert their internal stream type to ours.The text was updated successfully, but these errors were encountered: