I am having a problem with using NotesFTPSession Class work in a browser. Let me explainSeveral years ago, Paul Ray posted a notes database that carried a LotusScript class he created for FTP. I downloaded the file, and it worked as advertised in the Notes Client. My problem is that I need to activate it from a browser for our customers who access our web site and want to download the latest and greatest version of our software.
My dilemma is that it won’t operate in the browser. I tried triggering it from a WebQueryOpen event, through a direct link using ?OpenAgent, and nothing works. The script I am using is as follows:
' FTP Process
Dim drive As String
drive = doc.Drive(0)
Dim objFTP As NotesFTPSession
Set objFTP = New NotesFTPSession
With objFTP
.Connect "000.000.0.00", "download", "angel", 0 'server, user, password, flags
' .ChangeDirectory "d:\custdata"
.GetFile "JS-V2.1.5A.trs", drive+":\JS-V2.1.5A.trs", FTP_TRANSFER_TYPE_BINARY
.Disconnect
End With
Delete objFTP
Subject: NotesFTP Class
Have you tried adding error handling, like this:Sub Initialize
On Error Goto catch
’ Your code…
finally:
Exit Sub
catch:
Print "Error " & Err() & " at " & Lsi_Info(2) & ", line " & Erl() & ": " & Error()
Resume finally
End Sub
Does that give anything interesting? Have you tried to insert some debug “logging” before/in between/after you FTP-statements, to see if all code is executed?
johan@kanngard.net
http://dev.kanngard.net
Subject: RE: NotesFTP Class
Does this look correct - entered as is, and saw nothing
Sub Initialize
On Error Goto catch
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim drive As String
Set doc = s.DocumentContext
drive = doc.Drive(0)
Dim objFTP As NotesFTPSession
Set objFTP = New NotesFTPSession
With objFTP
.Connect "192.168.4.22", "download", "angel", 0 'server, user, password, flags
' .ChangeDirectory "d:\custdata"
' .GetFile "JS-V6.2.5A.trs", drive+":\JS-V6.2.5A.trs", FTP_TRANSFER_TYPE_ASCII
.GetFile "autostart.zip", "c:\autostart.zip", FTP_TRANSFER_TYPE_ASCII
.Disconnect
End With
Delete objFTP
finally:
Exit Sub
catch:
Print "Error " & Err() & " at " & Lsi_info(2) & ", line " & Erl() & ": " & Error()
Resume finally
End Sub
Subject: RE: NotesFTP Class
Only result is a page with “Agent Done”
Subject: RE: NotesFTP Class
Have you tried making a very simple FTP transfer with only a get?
johan@kanngard.net
http://dev.kanngard.net
Subject: RE: NotesFTP Class
The code works in the Notes Client - so it is “getting” something.I am very new to the FTP process - manager of the department requested this, and my boss said sure.
Can you help me understand a “very simple FTP transfer with only a get”
Running the DOS command line, I was able to “get” the target file.
Subject: NotesFTP Class
Hey Wayne,
The same reason why it wasn’t working from the Webqueryopen event. Any agent that you try to run from the web, runs on the server. So when the agent says to put the file at d:\wherever, it is putting(or attempting to put) the file in that path on the server. The only thing I can think of if you want to use that FTP class is to download the file and attach it to a NotesDocument. Then open that document up to the user. The other way was to use the ftp:// protocol inherent in Browsers.
Subject: RE: NotesFTP Class
Brian - good thought - let me check if it is there
Can you think of an alternative method of doing an FTP from a web page…rationale, user likes the speed of download with FTP process
Subject: RE: NotesFTP Class
Like I said before, browser will do FTP if you pass it the right address string. For instance if you wanted to download a random file from the Lotus ftp you would put the following address in the address bar: ftp://ftp.lotus.com/pub/lotusweb/product/notesr5/rn_ccmc.nsf . It should ask you if you would like to open it where it is or save it. The syntax is ftp://[username]:[password]@[ftpaddress]:[port]/[path to file]
Subject: RE: NotesFTP Class
ftp://[username]:[password]@[ftpaddress]:[port]/[path to file]
Keep that security risk in mind if you go with passing a URL to the browser.
You’ll probably be much better off downloading the file to the server and linking the user either to that or to a document attachment made with that file.
Subject: A bit of a rethink needed?
Hi Wayne,you might need to revisit your requirements. When you run the FTP class on the server stuff will get downloaded into a server directory (and rott there). If you just want to facilitate the start of the download to the users workstation Printing the ftp URL in does the trick…
However the cool solution:
Get the file, get the contex information, create a notes document, attach the file and present the document to the user. That solution makes a lot of sense if you can anticipate the downloads (e.g. get the daily sales report from a remote site every night).
You might move from LotusScript to Java then. In Java you could use the Jakarta Commons lib for FTP, get the file as an inputstream, create a DXL around it and create a document on the fly. This way no download in a temp directory is needed.
stw