Repository navigation
Conversation
FileUploadToResourceField sends all its files in one multipart request. After a dropped connection, a proxy timeout or a reload of the page, a large file has to be sent again from its first byte. It cannot be paused, and a proxy may refuse a request that large. wicket-extensions gets ResumableUploadToResourceField, a subclass of FileUploadToResourceField. Each of its files goes in chunks, over the open tus protocol 1.0, to a ResumableUploadResourceReference that the application mounts once, as it mounts FileUploadResourceReference. Each upload can be paused, resumed and canceled. After a broken connection it goes on from the byte the server got to, once the browser is online again. The browser remembers unfinished uploads in localStorage, so the same file chosen after a reload or a browser restart goes on where it stopped. Once a file is whole the reference hands it to the application's IUploadsFileManager, and the field reports it to onUploadSuccess() as an UploadInfo, exactly as for the multipart resource. The limits, the failure and cancel hooks, FileDropZoneBehavior and FileListBehavior all work as before. The list shows each file's progress, with buttons to pause, resume and cancel it. The script is plain JavaScript and builds on Wicket.FileUploadToResourceField. Neither side adds a dependency. Every request carries the field's id and limits, signed with the application's crypt, as the query of the multipart resource does. An upload belongs to the HTTP session that created it. The reference limits the size of a file and of a chunk, the uploads of a session and of all sessions, and the free space on disk. It deletes uploads the browser has not touched for a while, those of a session that ends, and all of them when the application stops. Wicket's filter answers OPTIONS itself, so the resource does not announce its tus version there; tus clients do not need it. Three small changes in wicket-core make the subclass possible. FileUploadToResourceField gets getUploadCallbackUrl(), so a subclass rendering its own script reports to the same callback. module-info now exports org.apache.wicket.markup.html.form.upload.resource: the package holds public API but was only opened, so an application on the module path could not use the upload to a resource. Javadoc now covers that package, and its raw generics are fixed. Applications that do not use the new field see no change. The upload examples get a "Resumable upload to a resource" page.
A React application or a mobile app has no ResumableUploadToResourceField to sign its requests, so the resource refused all of them. ResumableUploadResourceReference.newQuery() now creates the signed query for an id the application chooses and limits it sets. The names of the headers that carry the stored file name and the error key are now public constants of the reference. A client like that can complete an upload and hand the stored name back to the application, which finds the file in the file manager under its id.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## wicket-11.x #2011 +/- ##
=================================================
+ Coverage 62.73% 62.91% +0.17%
- Complexity 11512 11682 +170
=================================================
Files 1254 1260 +6
Lines 48669 49215 +546
Branches 6846 6903 +57
=================================================
+ Hits 30532 30962 +430
- Misses 15460 15549 +89
- Partials 2677 2704 +27 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #2010 to
wicket-11.x.ResumableUploadToResourceFieldandResumableUploadResourceReferencetowicket-extensions: each file goes to the resource in chunks over the tus protocol, can be paused, resumed and canceled, and goes on after a broken connection or a reload of the page. Once a file is whole it is handed to theIUploadsFileManager, andonUploadSuccess()receives it as forFileUploadToResourceField. See Add a resumable upload to a resource, sent in chunks over tus #2010 for the details.Gruntfile.js, because 11.x lists fewer JavaScript tests;@since 11.1.0instead of12.0.0.No API break, only additions:
wicket-extensions;FileUploadToResourceField.getUploadCallbackUrl(), protected final;org.apache.wicket.markup.html.form.upload.resourcein themodule-infoofwicket-core, which held public API but was only opened.japicmp against 11.0.0 reports no incompatible change. The default serialVersionUID of
FileUploadToResourceFieldchanges, as with any change to a component. Nothing to migrate.Verified on this branch:
mvn clean install -Pjs-testis green, japicmp included: 3373 Java tests, and 213 and 212 JavaScript tests (jQuery and vanilla engines), none failing.