diff --git a/dspace-api/src/main/java/org/dspace/scripts/DSpaceRunnable.java b/dspace-api/src/main/java/org/dspace/scripts/DSpaceRunnable.java index 2319aee3175..9f36dff1e5f 100644 --- a/dspace-api/src/main/java/org/dspace/scripts/DSpaceRunnable.java +++ b/dspace-api/src/main/java/org/dspace/scripts/DSpaceRunnable.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.UUID; import org.apache.commons.cli.CommandLine; @@ -158,4 +159,8 @@ public UUID getEpersonIdentifier() { public void setEpersonIdentifier(UUID epersonIdentifier) { this.epersonIdentifier = epersonIdentifier; } + + public Optional fileParameterToBitstreamType(String fileParameter) { + return Optional.empty(); + } } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/ScriptRestRepository.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/ScriptRestRepository.java index 1eea06a4ee8..a9772e44f62 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/ScriptRestRepository.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/ScriptRestRepository.java @@ -154,7 +154,7 @@ private void runDSpaceScript(List files, Context context, ScriptC dSpaceRunnable.initialize(args.toArray(new String[0]), restDSpaceRunnableHandler, context.getCurrentUser()); if (files != null && !files.isEmpty()) { checkFileNames(dSpaceRunnable, files); - processFiles(context, restDSpaceRunnableHandler, files); + processFiles(context, restDSpaceRunnableHandler, files, dSpaceRunnable); } restDSpaceRunnableHandler.schedule(dSpaceRunnable); } catch (ParseException e) { @@ -171,11 +171,12 @@ private void runDSpaceScript(List files, Context context, ScriptC } private void processFiles(Context context, RestDSpaceRunnableHandler restDSpaceRunnableHandler, - List files) - throws IOException, SQLException, AuthorizeException { + List files, DSpaceRunnable dspaceRunnable) + throws IOException, SQLException, AuthorizeException { for (MultipartFile file : files) { - restDSpaceRunnableHandler - .writeFilestream(context, file.getOriginalFilename(), file.getInputStream(), "inputfile"); + String type = (String) dspaceRunnable.fileParameterToBitstreamType(file.getName()) + .orElse("inputfile"); + restDSpaceRunnableHandler.writeFilestream(context, file.getOriginalFilename(), file.getInputStream(), type); } }