You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR was merged into the 2.x branch.
Discussion
----------
Enabling files upload
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| Tickets |
| License | MIT
Getting back on the file uploading front I've decided to go slowly this time, as in the end it should allow us to get basic support faster and then build up on it, without determining all the little details of both backend and frontend implementations upfront.
This PR aims at *enabling* frontend tools to send files back to the server. It does not add file upload functions to the live controller or handle the files on the backend. Instead it focuses only on changes that are essential to get any kind of file upload in the future.
What exactly is done here:
- `RequestBuilder` gets an additional parameter (`files`) that takes a map of `FileList` objects that should be uploaded with the request (and the keys by which they should be available). This additional parameter is added as an empty map everywhere right now.
- To make file upload possible the content type of a request is moved from JSON to the default (form type) and all the component related data is sent under `data` key.
- `RequestBuilder` tests are adapted to the changes and tests for appending files to the request are added.
- On the backend site `LiveComponentSubscriber` is adapted to read data from JSON-encoded `data` parameter instead of request content (in case of a POST request), without any further functional changes.
- All tests are adapted to send data in the new format.
Two tests are failing for me locally (and in 2 seemingly random CI configurations), while logic tells me they shouldn't and I'm unable to find the cause right now. Help would be appreciated.
I would love to get that first stepping stone finalized and merged before further work. It is a simple change, but has strong implications, therefore getting those out of the way will make further work much more comfortable. Also - splitting the work will hopefully make it easier for you to review.
Commits
-------
d29df00 Fixing test
380b492 phpcs
cc41980 [Upload] Updating demo
1a147a2 Adapt tests again
65e2794 Rewire files handling to actually send files only once and clear input afterwards
1f74e6d Clear pendingFiles after being sent
0e1013e Pump up docs
2155865 Stop using data-model on file inputs as an alternative. It's pointless
c74f689 Rebuild dist assets
c7c56f0 Use `expectException` to mitigate test failures.
cf8ef71 Code style
610b216 Add very simple upload files docs
7ea3fbb Add extremely simple upload files example
ad70f81 Hook up files in Component and build assets
458ba60 Add possibility to send files with an action
7fd6e5a Rebuild assets
fe69154 Read POST payload from `data` key instead of a request body
b5ff362 Add tests for passing files to RequestBuilder and make them pass
14a640b Make files mandatory in Backend.ts and pass empty map from controller
2d13c27 Allow files to be passed to `RequestBuilder` and move request body under 'data' key
0 commit comments