file system provisioner related changes

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@12252 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-09-20 18:11:44 +00:00
1 parent 674845c1ad
commit c3f4ead8a5
3 files changed
+35 -2

No files matched your search

+25
View File
@@ -25,6 +25,7 @@ import org.apache.tools.tar.TarOutputStream;
import org.apache.tools.zip.ZipOutputStream;
import org.apache.tools.zip.ZipEntry;
import org.apache.commons.io.IOUtils;
import org.apache.commons.fileupload.FileItem;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -326,6 +327,30 @@ public final class FilePath implements Serializable {
});
}
/**
* 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(new File(remote));
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException2(e);
}
} else {
InputStream i = file.getInputStream();
OutputStream o = write();
try {
IOUtils.copy(i,o);
} finally {
o.close();
i.close();
}
}
}
/**
* Code that gets executed on the machine where the {@link FilePath} is local.
* Used to act on {@link FilePath}.