public void copyTo0(OpsTarget target, File remoteFilePath) throws OpsException {
InetAddress host;
try {
host = InetAddress.getByName(uri.getHost());
} catch (UnknownHostException e) {
throw new OpsException("Unable to resolve host: " + uri, e);
}
if (InetAddressUtils.isPublic(host)) {
CurlRequest curlRequest = new CurlRequest(uri);
curlRequest.bareRequest = true;
CommandEnvironment commandEnvironment = httpProxies.getHttpProxyEnvironment(target, Usage.General, uri);
Command curlCommand = curlRequest.toCommand();
curlCommand.addLiteral(">");
curlCommand.addFile(remoteFilePath);
curlCommand.setEnvironment(commandEnvironment);
curlCommand.setTimeout(TimeSpan.FIVE_MINUTES);
target.executeCommand(curlCommand);
} else {
log.warn("Address was not public: " + host + ", doing copy via ops system");
File tempFile;
try {
tempFile = File.createTempFile("jenkins", "dat");
} catch (IOException e) {
throw new OpsException("Error creating temp file", e);
}
try {
InputStream is = uri.toURL().openStream();
try {
IoUtils.copyStream(is, tempFile);
} finally {
Closeables.closeQuietly(is);
}
FileUpload.upload(target, remoteFilePath, tempFile);
} catch (IOException e) {
throw new OpsException("Error copying jenkins artifact", e);
} finally {
tempFile.delete();
}
}