stable
Clone or download
part of story #36484 create a new project from an XML template How to test: - upload an image => REST route will throw you an error (to check in console > network of your brower) - upload an archive => an alter Displaying 'Done' will appears, all route are succesfull You can use the following snippet to test: ``` <input type="file" id="myfile"> document.getElementById('myfile').addEventListener('change', async (e) => { const file = e.target.files[0]; const post_response = await fetch(`/api/project_files`, { method: 'POST', credentials: 'same-origin', headers: { "Content-Type": "application/json", }, body: JSON.stringify({ file_name: file.name, file_size: file.size }) }); const post_response_body = await post_response.json(); const upload_href = post_response_body["upload_href"]; // Create a new tus upload const upload = new Upload(file, { uploadUrl: upload_href, retryDelays: [0, 3000, 5000], metadata: { filename: file.name, filetype: file.type }, 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(" %s uploaded to %s", upload.file.name, upload.url); alert('Done'); } }); // Start the upload upload.start(); }); ``` Change-Id: I60c4e6991c07c1fdaf9b037b8717ae4259b7e123
Modified Files
Name | ||||
---|---|---|---|---|
A | src/common/Project/Registration/Template/Upload/Tus/FileIsNotAnArchiveException.php | +32 | −0 | Go to diff View file |
M | src/common/Project/Registration/Template/Upload/Tus/ProjectFileUploadFinisher.php | +13 | −2 | Go to diff View file |
M | src/common/Request/RouteCollector.php | +4 | −1 | Go to diff View file |
M | tests/unit/common/Project/Registration/Template/Upload/Tus/ProjectFileUploadFinisherTest.php | +37 | −7 | Go to diff View file |
A | tests/unit/common/Project/Registration/Template/Upload/Tus/_fixtures/test.zip | Binary file | Go to diff View file |