OK, so using just cfscript without language="java" and using the CreateObject seems to work. it would have been nice if it would have worked the other way too though... Probably less "wonky" to get the rest of the code implemented. Den's version is also worth a try, also since it's allready in there. As long as I can upload a file under a defined user account over sftp it's OK. Wether it will be an add-on to cffile or cfftp is not so important... Unfortunately I'm not up-to-date with the newer versions of Adobe's ColdFusion or how Railo is solving this. I only know that CF8 had that impemented in CFFTP so when and if it will be implemented we should follow the standard to avoid confusion for the developers. Also from the name SFTP it's more an FTP task. But again. The majority should decide this... In the end it's the functionality that is needed... Or maybe I'm just the only one who needs it :) we'll see I will add it to the reqest and we'll see. I will now try to play around with both versions for a while. In Den's code sample there was a notice about closing the filemanager wich could?? explain your problem Matthew with your test on the second run.
Anyway thanks to both of you for helping out! /Mats/ On Tuesday, March 15, 2011, Matthew Woodward <[email protected]> wrote: > On Mon, Mar 14, 2011 at 1:33 PM, Mats Stromberg <[email protected]> > wrote: > > That's worth to look at if it's allready in there... Still it doesn't > explain how I can mess up such small template. > > Got a chance to mess with this a bit. I dropped jsch-0.1.44.jar in > {jetty-openbd-root}/webapps/openbd/WEB-INF/lib and that's definitely the > right spot. > > This code works: > <cfscript> > jsch = CreateObject("java", "com.jcraft.jsch.JSch").init(); > > WriteDump(jsch, "browser"); > abort; > </cfscript> > > So that shows it's instantiating the JSch class correctly. > > Beyond that things get wonky rather quickly, particularly when you dig into > the mechanics of transferring files. In order to avoid wanting to shoot > yourself every time you did this you'd want to write some wrapper classes and > methods. Either I'm not that smart this evening or this is just really nasty. > > I think Denny's on the right track with the VFS suggestion in the short term. > Apache Commons VFS is included with OpenBD, so I took Denny's earlier example > and modified a bit and it works--this downloads a file over SFTP. > > <cfscript> > fso = CreateObject("java", > "org.apache.commons.vfs.FileSystemOptions").init(); > CreateObject("java", > "org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder").getInstance().setStrictHostKeyChecking(fso, > "no"); > > fsManager = CreateObject("java", > "org.apache.commons.vfs.VFS").getManager(); > > uri = "sftp://user:password@host:port/path/to/remote/File.cfc"; > > fo = fsManager.resolveFile(uri, fso); > > bis = CreateObject("java", > "java.io.BufferedInputStream").init(fo.getContent().getInputStream()); > > fos = CreateObject("java", > "java.io.FileOutputStream").init("/local/path/to/write/File.cfc"); > bos = CreateObject("java", "java.io.BufferedOutputStream").init(fos); > > while ((c = bis.read()) != -1) { > bos.write(c); > } > > bos.close(); > fos.close(); > fo.close(); > fsManager.close(); > </cfscript> > > I did run into a bug with this code in that it works once but if you try to > run it again, you'll get the "unknown scheme" error outlined here (do a > ctrl-F for "unknown scheme"): > http://wiki.apache.org/commons/SimpleSftpFileDownload > > Which appears to be addressable but not by me tonight at any rate. ;-) Hope > that at least gets you started. > > Also please submit a ticket if you didn't already do so for SFTP support. Do > you care if it's in the CFFTP tag for compatibility with Adobe CF, or should > this be incorporated into CFFILE and SFTP is just another resource, or > something else people would like to see? > -- > Matthew Woodward > [email protected] > http://blog.mattwoodward.com > identi.ca / Twitter: @mpwoodward > > Please do not send me proprietary file formats such as Word, PowerPoint, etc. > as attachments. > http://www.gnu.org/philosophy/no-word-attachments.html > > > -- > official tag/function reference: http://openbd.org/manual/ > mailing list - http://groups.google.com/group/openbd?hl=en > -- official tag/function reference: http://openbd.org/manual/ mailing list - http://groups.google.com/group/openbd?hl=en
