GitHub user zentol opened a pull request:
https://github.com/apache/flink/pull/6178
[FLINK-9599][rest] Implement generic mechanism to access uploaded files
## What is the purpose of the change
This PR extends the existing multipart handling to also support mixed
multipart message (i.e. requests containing both JSON and files), and
generalizes the `FileUpload` handling to provide access to all handlers
extending `AbstractHandler`
Handlers may access uploaded files via `HandlerRequest#getFileUploads`.
File uploads must be explicitly allowed by returning true in
`MessageHeaders#acceptsFileUploads`.
The files and JSON payload are forwarded to the handler by the
`FileUploadHandler` via channel attributes. If a JSON payload is forwarded this
way a handler will ignore the content of the received `HttpRequest`.
This PR only covers the server-side; the `RestClient` remains unchanged.
This will be done in a follow-up.
## Brief change log
* add `MessageHeaders#acceptsFileUploads` to signal that a handler accepts
file uploads (default=false)
* add `FileUploads` class as a container for uploaded files
* extend `FileUploadHandler` to
* accept multiple files in one request
* also accept a JSON payload
* forward both files and json via channel attributes
* extend `AbstractHandler` to retrieve files/json from channel attributes
* remove special case for `JarRunHandler` in `AbstractHandler`
* extend `HandlerRequest` to accept a `FileUploads` object
* add `OkHttp` dependency to `flink-runtime` for testing purposes
* update `JarUploadHandler/Headers`
## Verifying this change
added tests:
* FileUploadsTest
* FileUploadHandlerTest
* manually verified via WebUI job submission
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes)
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (yes)
- If yes, how is the feature documented? (not documented)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/zentol/flink 9280_beta
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/6178.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #6178
----
commit c2adb3880180d8426697c33035d2b31d57d93952
Author: zentol <chesnay@...>
Date: 2018-06-18T08:54:42Z
[FLINK-9599][rest] Implement generic mechanism to access uploaded files
----
---