Fix file download in data explorer
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 6 Mar 2018 11:46:26 +0000 (12:46 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 6 Mar 2018 11:46:26 +0000 (12:46 +0100)
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/JcrDClickListener.java

index 3cee13a2ccb0e211ee6d6f4271c35962128da7aa..cbd9928fd27e9e7b33ab270fc842e34c1eb6ad45 100644 (file)
@@ -120,9 +120,13 @@ public class JcrDClickListener implements IDoubleClickListener {
                                                suffix = name.substring(i);
                                        }
                                        Binary binary = null;
-                                       try (OutputStream os = new FileOutputStream(tmpFile)) {
+                                       try {
                                                tmpFile = File.createTempFile(prefix, suffix);
                                                tmpFile.deleteOnExit();
+                                       } catch (IOException e1) {
+                                               throw new EclipseUiException("Cannot create temp file", e1);
+                                       }
+                                       try (OutputStream os = new FileOutputStream(tmpFile)) {
                                                binary = node.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary();
                                                try (InputStream is = binary.getStream();) {
                                                        IOUtils.copy(is, os);