From ad215e31be9ad5c44f6efe35f7c9e6c83b5419a2 Mon Sep 17 00:00:00 2001 From: milanmajchrak <90026355+milanmajchrak@users.noreply.github.com> Date: Mon, 6 May 2024 09:30:43 +0200 Subject: [PATCH] Upload big file differencies (#647) * Update hint for big file upload * Do not delete big file after upload by default - changed cfg property. * Refactored checking if the file should be deleted after upload. * Remove big file metadata after every save metadata --- .../app/rest/repository/WorkspaceItemRestRepository.java | 7 +++++-- dspace/config/clarin-dspace.cfg | 4 ++-- dspace/config/submission-forms.xml | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/WorkspaceItemRestRepository.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/WorkspaceItemRestRepository.java index 3add833152e9..d3fb87b0e501 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/WorkspaceItemRestRepository.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/WorkspaceItemRestRepository.java @@ -466,9 +466,12 @@ private void uploadFileFromURL(Context context, HttpServletRequest request, Inte wis.update(context, witem); + // remove metadata from the item, because that file was uploading after every save + itemService.clearMetadata(context, witem.getItem(), "local", "bitstream", "redirectToURL", Item.ANY); + // delete file - String shouldDeleteFile = configurationService.getProperty("delete.big.file.after.upload"); - if (StringUtils.isNotBlank(shouldDeleteFile) && StringUtils.equals("true", shouldDeleteFile)) { + boolean shouldDeleteFile = configurationService.getBooleanProperty("delete.big.file.after.upload", false); + if (shouldDeleteFile) { FileUtils.forceDelete(file); } } diff --git a/dspace/config/clarin-dspace.cfg b/dspace/config/clarin-dspace.cfg index c6f9552ffb2b..ff3a44805085 100644 --- a/dspace/config/clarin-dspace.cfg +++ b/dspace/config/clarin-dspace.cfg @@ -64,8 +64,8 @@ lr.help.mail = test@test.sk lr.help.phone = 0000 # Admin could upload the file bigger than maximum upload size. -# Should be this big file deleted from the '/temp' folder? -delete.big.file.after.upload = true +# Should be this big file deleted from where it was uploaded? +delete.big.file.after.upload = false ##### BITSTREAM DOWNLOAD ##### diff --git a/dspace/config/submission-forms.xml b/dspace/config/submission-forms.xml index 0acba1b87086..304d8d0cb076 100644 --- a/dspace/config/submission-forms.xml +++ b/dspace/config/submission-forms.xml @@ -393,10 +393,10 @@ onebox - The actual maximum upload size of the file is 4GB. To upload the file bigger than maximum - upload size type the URL of that big file. Admin must know URL to that bitstream file. - Then click on the 'Save' button and the file will start to upload. The file will be loaded - from the '/temp' folder of the server. Example: /tomcat/temp/bitstream.png + The actual maximum upload size of the file is 4GB. To upload a file bigger than the + maximum upload size, enter the URL of that large file. The admin must know the URL + of that bitstream file. Then, click on the 'Save' button, and the file will start + to upload. The file path must be an absolute path.