Detaching an uploaded file on server with JAVA

I’m Having trouble detaching a file from an RTF. Here’s my code…

Although I have the _inputFileName identified as a String above, and have it in the field called FileName, I’m still getting FileName: Null through my debug lines.

void detachFile() {

String _inputFileName = “”; // gwl a

try {

boolean saveFlag = false;

                	                _inputFileName = thisDoc.getItemValueString("FileName");

	 		       RichTextItem body = (RichTextItem)thisDoc.getFirstItem("$File");

if (trace) System.out.println("Item name: " +body.getName());

Vector v = body.getEmbeddedObjects();

	 		       Enumeration e = v.elements();

while (e.hasMoreElements()) {

      		 		 EmbeddedObject eo = (EmbeddedObject)e.nextElement();

if (eo.getType() == EmbeddedObject.EMBED_ATTACHMENT) {

	 	   		 	    	eo.extractFile( _inputFileName );

	           

	 		            	// now we'll remove the file from the Notes Document...

                             	eo.remove();

      		              	saveFlag = true;

		      		 	}



	 		     		 if (saveFlag) {

 		          		 thisDoc.save(true, true);

                          	 saveFlag = false;

						}

                        }

		         } catch(NotesException e) {

		       System.out.println(e.id + " " + e.text);

e.printStackTrace();

}catch(Exception e) {

e.printStackTrace();

    }

} //detachFile()

I pretty much took this from the help file. Can someone help me get this working? I also have to understand exactly where the server puts this file when we detach it. Is it in the folder (directory) that the NSF is in?

Help!

Marcus

Subject: detaching an uploaded file on server with JAVA…

  1. Document must be saved before you can find attachmnets.2) Attachments saved from Web browser are not in richtext field, they are directly in document. Use EmbeddedObject obj=doc.getAttachment(“file.zip”) to set handle to attachment.

  2. On client if you do not specify path, files get saved to c:\notes6client\ folder, on server they most probably get saved to c:\domino6server\Domino\ folder, I could not test this today.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {

  Session session = getSession();

  AgentContext agentContext = session.getAgentContext();

  Database db = agentContext.getCurrentDatabase();

    Document doc =  db.getDocumentByUNID("C9030AAD883E062CC1256E0B0858FED6");

    EmbeddedObject obj =  doc.getAttachment("bubbles-evil.mp3");

    if (obj != null) {

       obj.extractFile(obj.getSource());

       System.out.println("Extracting "+obj.getSource());

       }      

} catch(Exception e) {

  e.printStackTrace();

}

}

}