@Override public void init(Map<String, String> config) { String dir; if ((dir = config.get(CONFIG_DIRECTORY)) != null) { directory = dir; } ensureDirExists(); }
@Override public void init(Map<String, String> config) { String dir; if ((dir = config.get(CONFIG_DIRECTORY)) != null) { directory = dir; } ensureDirExists(); }
@Override public void init(Map<String, String> config) { String dir; if ((dir = config.get(CONFIG_DIRECTORY)) != null) { directory = dir; } ensureDirExists(); }
@Override public boolean delete(String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); return Files.deleteIfExists(path); }
@Override public boolean delete(String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); return Files.deleteIfExists(path); }
@Override public boolean deleteFile(String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); return Files.deleteIfExists(path); }
@Override public InputStream downloadFile(String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); File file = path.toFile(); return new FileInputStream(file); }
@Override public InputStream download(String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); File file = path.toFile(); return new FileInputStream(file); }
@Override public InputStream download(String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); File file = path.toFile(); return new FileInputStream(file); }
@Override public String upload(InputStream inputStream, String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); File file = path.toFile(); if (!file.createNewFile()) { throw new IOException("File: ["+name+"] already exists"); } try (OutputStream outputStream = new FileOutputStream(file)) { ByteStreams.copy(inputStream, outputStream); } return path.toString(); }
@Override public String uploadFile(InputStream inputStream, String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); File file = path.toFile(); if (!file.createNewFile()) { throw new IOException("File: [" + name + "] already exists"); } try (OutputStream outputStream = new FileOutputStream(file)) { ByteStreams.copy(inputStream, outputStream); } return path.toString(); }
@Override public String upload(InputStream inputStream, String name) throws IOException { ensureDirExists(); Path path = FileSystems.getDefault().getPath(directory, name); File file = path.toFile(); if (!file.createNewFile()) { throw new IOException("File: ["+name+"] already exists"); } try (OutputStream outputStream = new FileOutputStream(file)) { ByteStreams.copy(inputStream, outputStream); } return path.toString(); }