• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: File Upload/scp problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File Upload/scp problem


  • Subject: Re: File Upload/scp problem
  • From: Pascal Robert <email@hidden>
  • Date: Mon, 12 Jul 2004 21:36:16 -0400

Try a SSH API instead.

https://3sp.com/catalog/products/sshtools/j2ssh/introduction.php
http://jakarta.apache.org/commons/sandbox/vfs/apidocs/org/apache/ commons/vfs/provider/sftp/SftpClientFactory.html



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.
_______________________________________________
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.


References: 
 >File Upload/scp problem (From: "Carlile, Don" <email@hidden>)

  • Prev by Date: File Upload/scp problem
  • Next by Date: Re: WO Developers in FL
  • Previous by thread: File Upload/scp problem
  • Next by thread: Re: WO Developers in FL
  • Index(es):
    • Date
    • Thread