« Return to the blog entry
ok well here's an agent i have semi-working in that it retrieves txt files eg. boot.ini from the server root.
it runs unrestricted .. and you call it like : http://yourserver/yourdb.nsf/getfile?openagent&file=c:\boot.ini
//code//
import java.util.Vector;
import java.io.InputStream;
import java.io.*;
import sun.misc.BASE64Encoder;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Document doc = agentContext .getDocumentContext();
Vector vec=session.evaluate("@right(QUERY_STRING_DECODED ; '&file=')",doc);
String file2get = vec.firstElement().toString();
System.out.println( file2get );
OutputStream agentout = this.getAgentOutputStream();
agentout.write("Content-Type: application/octet-stream\n".getBytes());
// get an input stream for the attachment
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(file2get);
// write bytes from input stream to output stream
byte[] bytes = new byte[1];
while ( fileInputStream.read(bytes) > -1) {
agentout.write(bytes);
}
// flush and close
agentout.flush();
agentout.close();
} catch(Exception e) {
e.printStackTrace();
maybe you can see something I am missing here..
thx.
ok well here's an agent i have semi-working in that it retrieves txt files eg. boot.ini from the server root.
it runs unrestricted .. and you call it like : http://yourserver/yourdb.nsf/getfile?openagent&file=c:\boot.ini
//code//
import java.util.Vector;
import java.io.InputStream;
import java.io.*;
import sun.misc.BASE64Encoder;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Document doc = agentContext .getDocumentContext();
Vector vec=session.evaluate("@right(QUERY_STRING_DECODED ; '&file=')",doc);
String file2get = vec.firstElement().toString();
System.out.println( file2get );
OutputStream agentout = this.getAgentOutputStream();
agentout.write("Content-Type: application/octet-stream\n".getBytes());
// get an input stream for the attachment
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(file2get);
// write bytes from input stream to output stream
byte[] bytes = new byte[1];
while ( fileInputStream.read(bytes) > -1) {
agentout.write(bytes);
}
// flush and close
agentout.flush();
agentout.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
maybe you can see something I am missing here..
thx.