stable
Clone or download
The tus.io protocol will allow us to deal with resumable uploads in the document manager with a well documented protocol. The implementation of the tus server uses PSR-7 messages to ease the re-usability and interoperability of it. A HTTP route is added under /uploads/docman/file in order to test the proposed implementation of the tus.io protocol [0]. This route is only accessible when a flag enable_tus_test_endpoint has this route does not handle any permission or do something useful. The endpoint expects a file of 1MB, on a Linux system you can generate such a file with something like head -c 1M /dev/urandom > /tmp/1M.bin. You can play with the tus endpoint with a small page like: <!doctype html> <html lang="en"> <head> <title>Test tus.io</title> <script src="https://example.com/tus.min.js"></script> </head> <body> <input type="file" id="input-file"> <script> document.getElementById('input-file').addEventListener("change", function(e) { const file = e.target.files[0]; const upload = new tus.Upload(file, { uploadUrl: "/uploads/docman/file", retryDelays: [0, 1000, 3000, 5000], onError: function(error) { console.log("Failed because: " + error) }, onProgress: function(bytesUploaded, bytesTotal) { const percentage = (bytesUploaded / bytesTotal * 100).toFixed(2); console.log(bytesUploaded, bytesTotal, percentage + "%") }, onSuccess: function() { console.log("Download %s from %s", upload.file.name, upload.url) } }); upload.start() }) </script> </body> </html> You will find the file on the server stored at /tmp/test_upload. You can remove it to try again. This is part of story #12612: upload document via REST route [0] https://tus.io/protocols/resumable-upload.html Change-Id: I23d9502e6d705d0761ca38e0ba554e28207f55c7
Modified Files
Name | ||||
---|---|---|---|---|
A | plugins/docman/include/Tus/CannotWriteFileException.php | +29 | −0 | Go to diff View file |
A | plugins/docman/include/Tus/TusFile.php | +39 | −0 | Go to diff View file |
A | plugins/docman/include/Tus/TusServer.php | +144 | −0 | Go to diff View file |
A | plugins/docman/include/Tus/TusServerException.php | +25 | −0 | Go to diff View file |
A | plugins/docman/include/Tus/TusServerIncompatibleVersionException.php | +29 | −0 | Go to diff View file |
A | plugins/docman/include/Upload/DocumentToUpload.php | +81 | −0 | Go to diff View file |
A | plugins/docman/include/Upload/FileUploadController.php | +66 | −0 | Go to diff View file |
M | plugins/docman/include/docmanPlugin.class.php | +12 | −0 | Go to diff View file |
A | plugins/docman/tests/phpunit/Tus/TusServerTest.php | +245 | −0 | Go to diff View file |
M | tests/phpunit/phpunit.xml | +1 | −0 | Go to diff View file |