File Upload/scp problem
File Upload/scp problem
- Subject: File Upload/scp problem
- From: "Carlile, Don" <email@hidden>
- Date: Mon, 12 Jul 2004 17:42:11 -0700
Hello All,
A couple weeks ago when I was at WWDC, it seemed that there was a comment in
about all of the WebObjects sessions about not saving graphics in the
database, but put it on the server. OK, I thought, I'm only doing that in
one place, and it's not working particularly well. I'll just take care of
that when I get back.
We have a database server, two appservers, and a webserver. So I need to
get a graphics file that's uploaded by a user from the appserver to the
webserver. Easy, I figure. So I set the File Upload component to upload
the file to /tmp and tried this code:
editingContext.saveChanges();
String theCommand = "scp /tmp/" +
NSPathUtilities.lastPathComponent(theProject.logoPath())
+ "user@webserveraddress:/webpath/";
try {
Runtime theRuntime = Runtime.getRuntime();
Process copyFile = theRuntime.exec(theCommand);
copyFile.waitFor();
} catch (Exception e) {
System.out.println(e);
}
I had previously set up public/private key pairs appropriately between my
machine and the server, so running under Xcode worked just fine.
Great, I think, I can deploy now and I'm done. I set up the keys between my
normal user on the appserver and the webserver, and deployed. For some
reason, it worked fine, and I headed off for the weekend with a happy heart.
I did some more cleanup this morning and tried it again. Failure. So, I
had a few nore thoughts through the day and instrumented the code a bit more
to see if I could figure out what was going on. I'm pretty sure it
shouldn't have worked when first deployed, because the keys weren't set up
for the user "appserver". So here is the latest incarnation of the code:
editingContext.saveChanges();
String theCommand = "scp -i /pathToPrivateKey /tmp/" +
NSPathUtilities.lastPathComponent(theProject.logoPath())
+ "user@webserveraddress:/webpath
System.out.println(theCommand);
String inString = "";
try {
Runtime theRuntime = Runtime.getRuntime();
Process copyFile = theRuntime.exec(theCommand);
BufferedReader theReader = new BufferedReader(new
InputStreamReader(copyFile.getErrorStream()));
try {
inString = theReader.readLine();
System.out.println(inString);
} catch (IOException e) {
System.out.println(e);
}
copyFile.waitFor();
} catch (Exception e) {
System.out.println(e);
}
If I issue the scp from the command line, the copy works correctly. In the
context of the app, the Process error is " Host key verification failed."
So, can anyone see what I am doing wrong? Or is there a better way to get
my uploaded file from the appserver to the webserver?
Thanks!
Don Carlile
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.