diff --git a/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferServlet.java b/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferServlet.java index c1dcf52b53..073cbc38a8 100644 --- a/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferServlet.java +++ b/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferServlet.java @@ -34,6 +34,7 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Map; public class WebDataTransferServlet extends WebServiceServletBase { @@ -67,7 +68,7 @@ protected void processServiceRequest(WebSession session, HttpServletRequest requ } String fileName = taskInfo.getExportFileName(); if (!CommonUtils.isEmpty(fileName)) { - fileName += "." + WebDataTransferUtils.getProcessorFileExtension(processor); + fileName += "." + WebDataTransferUtils.getProcessorFileExtension(processor, taskInfo.getParameters().getProcessorProperties()); } else { fileName = taskInfo.getDataFileId(); } diff --git a/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferUtils.java b/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferUtils.java index b0ac4d45fd..d05129736a 100644 --- a/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferUtils.java +++ b/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebDataTransferUtils.java @@ -23,9 +23,12 @@ import org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor; import org.jkiss.utils.CommonUtils; +import java.util.Map; + class WebDataTransferUtils { private static final Log log = Log.getLog(WebDataTransferUtils.class); + public static final String EXTENSION = "extension"; public static String getProcessorFileExtension(DataTransferProcessorDescriptor processor) { @@ -34,6 +37,14 @@ public static String getProcessorFileExtension(DataTransferProcessorDescriptor p return CommonUtils.isEmpty(ext) ? "data" : ext; } + public static String getProcessorFileExtension(DataTransferProcessorDescriptor processor, Map processorProperties) { + if (processorProperties != null && processorProperties.get(EXTENSION) != null) { + return CommonUtils.toString(processorProperties.get(EXTENSION), "data"); + } + + return getProcessorFileExtension(processor); + } + public static String normalizeFileName( @NotNull String fileName, @NotNull WebDataTransferOutputSettings outputSettings diff --git a/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebServiceDataTransfer.java b/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebServiceDataTransfer.java index f503fc3dfb..d76d32034f 100644 --- a/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebServiceDataTransfer.java +++ b/server/bundles/io.cloudbeaver.service.data.transfer/src/io/cloudbeaver/service/data/transfer/impl/WebServiceDataTransfer.java @@ -107,7 +107,15 @@ public WebAsyncTaskInfo dataTransferExportDataFromContainer( } @NotNull - private String makeUniqueFileName(WebSQLProcessor sqlProcessor, DataTransferProcessorDescriptor processor) { + private String makeUniqueFileName( + WebSQLProcessor sqlProcessor, + DataTransferProcessorDescriptor processor, + Map processorProperties + ) { + if (processorProperties != null && processorProperties.get(StreamConsumerSettings.PROP_FILE_EXTENSION) != null) { + return sqlProcessor.getWebSession().getSessionId() + "_" + UUID.randomUUID() + + "." + processorProperties.get(StreamConsumerSettings.PROP_FILE_EXTENSION); + } return sqlProcessor.getWebSession().getSessionId() + "_" + UUID.randomUUID() + "." + WebDataTransferUtils.getProcessorFileExtension(processor); } @@ -157,7 +165,8 @@ public void run(DBRProgressMonitor monitor) throws InvocationTargetException { monitor.beginTask("Export data", 1); try { monitor.subTask("Export data using " + processor.getName()); - Path exportFile = dataExportFolder.resolve(makeUniqueFileName(sqlProcessor, processor)); + Path exportFile = dataExportFolder.resolve( + makeUniqueFileName(sqlProcessor, processor, parameters.getProcessorProperties())); try { exportData(monitor, processor, dataContainer, parameters, resultsInfo, exportFile); } catch (Exception e) {