public String uploadFileToStorage(InputStream inputStream, String jarFileName) throws IOException { return fileStorage.upload(inputStream, jarFileName); }
public String uploadFileToStorage(InputStream inputStream, String jarFileName) throws IOException { return fileStorage.upload(inputStream, jarFileName); }
@Override public String uploadFile(InputStream inputStream) { String fileName = UUID.randomUUID().toString(); try { String uploadedFilePath = fileStorage.upload(inputStream, fileName); } catch (IOException e) { throw new RuntimeException(e); } return fileName; }
private String uploadJar(File inputFile, String udfName) { String jarFileName; try (InputStream is = new FileInputStream(inputFile)) { jarFileName = String.format("streamline-functions-%s.jar", UUID.randomUUID().toString()); String uploadedPath = this.fileStorage.upload(is, jarFileName); LOG.debug("Jar uploaded to {}", uploadedPath); } catch (IOException ex) { LOG.error("Got exception when uploading jar", ex); throw new RuntimeException(ex); } return jarFileName; }
private String uploadJar(InputStream is, String notifierName) throws IOException { String jarFileName; if (is != null) { jarFileName = String.format("notifiers-%s.jar", UUID.randomUUID().toString()); String uploadedPath = this.fileStorage.upload(is, jarFileName); LOG.debug("Jar uploaded to {}", uploadedPath); } else { String message = String.format("Notifier %s jar content is missing.", notifierName); LOG.error(message); throw new IllegalArgumentException(message); } return jarFileName; } }
@Test public void testJarStorage() throws IOException { FileStorage fileStorage = getFileStorage(); File file = File.createTempFile("test", ".tmp"); file.deleteOnExit(); List<String> lines = Lists.newArrayList("test-line-1", "test-line-2"); Files.write(file.toPath(), lines, Charset.forName("UTF-8")); String name = "file.name"; // delete the file if it already exists fileStorage.delete(name); fileStorage.upload(new FileInputStream(file), name); InputStream inputStream = fileStorage.download(name); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); String nextLine; List<String> actual = Lists.newArrayList(); while((nextLine = bufferedReader.readLine()) != null) { actual.add(nextLine); } Assert.assertEquals(lines, actual); } }