/** * Place the data from {@link FileItem} into the file location specified by this {@link FilePath} object. */ public void copyFrom(FileItem file) throws IOException, InterruptedException { if(channel==null) { try { file.write(writing(new File(remote))); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } else { try (InputStream i = file.getInputStream(); OutputStream o = write()) { org.apache.commons.io.IOUtils.copy(i,o); } } }
/** * Writes to this file. * If this file already exists, it will be overwritten. * If the directory doesn't exist, it will be created. * * <P> * I/O operation to remote {@link FilePath} happens asynchronously, meaning write operations to the returned * {@link OutputStream} will return without receiving a confirmation from the remote that the write happened. * I/O operations also happens asynchronously from the {@link Channel#call(Callable)} operations, so if * you write to a remote file and then execute {@link Channel#call(Callable)} and try to access the newly copied * file, it might not be fully written yet. * * <p> * */ public OutputStream write() throws IOException, InterruptedException { if(channel==null) { File f = new File(remote).getAbsoluteFile(); mkdirs(f.getParentFile()); return Files.newOutputStream(fileToPath(writing(f))); } return act(new WritePipe()); } private class WritePipe extends SecureFileCallable<OutputStream> {
IOUtils.copy(input, writing(f));
File parent = f.getParentFile(); if (parent != null) mkdirs(parent); writing(f);
/** * Place the data from {@link FileItem} into the file location specified by this {@link FilePath} object. */ public void copyFrom(FileItem file) throws IOException, InterruptedException { if(channel==null) { try { file.write(writing(new File(remote))); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } else { try (InputStream i = file.getInputStream(); OutputStream o = write()) { org.apache.commons.io.IOUtils.copy(i,o); } } }
mkdirs(f.getParentFile()); try { return Files.newOutputStream(writing(f).toPath()); } catch (InvalidPathException e) { throw new IOException(e);
IOUtils.copy(input, writing(f));
File parent = f.getParentFile(); if (parent != null) mkdirs(parent); writing(f);