I still can not upload using the following code...any help would be valuable
String webPage = "http://myServer.com";
String name = "admin";
String password = "admin";
String authString = name + ":" + password;
byte[] authEncBytes =
Base64.encodeBase64(authString.getBytes());
String authStringEnc = new
String(authEncBytes);
URL url = new URL(webPage);
HttpURLConnection urlConnection =
(HttpURLConnection)
url.openConnection();
urlConnection = (HttpURLConnection)
url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic "
+ authStringEnc);
urlConnection.setRequestProperty("repositoryId", "releases");
urlConnection.setRequestProperty("groupId ",
CreateConfigurationFile.groupId);
urlConnection.setRequestProperty("artifactId ",
CreateConfigurationFile.artifactId);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
OutputStreamWriter out = new
OutputStreamWriter(urlConnection.getOutputStream());
File file = new File(
"C:/Documents and
Settings/kgiannou/.m2/repository/Test/Test/1/Test-1.jar");
try {
FileInputStream fis = new
FileInputStream(file);
char current;
while (fis.available() > 0) {
current = (char) fis.read();
out.write(current);
}
} catch (IOException e) {
e.printStackTrace();
}
out.close();
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new
InputStreamReader(is);
int numCharsRead = 0;
char[] charArray = new char[1024];
StringBuffer sb = new StringBuffer();
while ((numCharsRead = isr.read(charArray)) >
0) {
sb.append(charArray, 0, numCharsRead);
}
String result = sb.toString();
System.out.println(result);
--
View this message in context:
http://maven.40175.n5.nabble.com/Deploy-artifact-programmatically-tp4315124p4326883.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]