Re: FileUpload help...
Re: FileUpload help...
- Subject: Re: FileUpload help...
- From: James Cicenia <email@hidden>
- Date: Sat, 20 Mar 2004 16:17:08 -0600
Ignore this message... I forgot to rebuild my project after making
a change in my WOBuilder file.
-James
On Mar 20, 2004, at 4:09 PM, James Cicenia wrote:
Hello -
I created what I thought was a simple upload but I get nothing??
just this in my log: 47254 [WorkerThread10] INFO
er.extensions.ERXNSLogLog4jBridge - <WOHttpIO>: Drained socket
here is my code... it doesn't even get to any of my own System.outs:
// Generated by the WOLips Core at Sat Mar 20 13:38:29 CST 2004
import java.io.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import eo.*;
public class UploadFile extends WOComponent {
public NSData theFileData;
public String theFileName;
public String theMimeType;
public UploadFile(WOContext context) {
super(context);
}
public WOComponent uploadFile(){
if((theFileName != null)&&
(theFileName.length()>0)){
//get the output file
File outDir = new File(System.getProperty("java.io.tmpdir"));
File outFile = new File(outDir.getAbsolutePath() + File.separator +
theFileName);
String fullPath = outDir.getAbsolutePath() + File.separator +
theFileName;
System.out.println("full path is "+fullPath);
EOEditingContext ec = session().defaultEditingContext();
ProjectDocuments theDatabaseDocument = new ProjectDocuments();
ec.insertObject(theDatabaseDocument);
theDatabaseDocument.setAddUser(((Session)session()).user());
theDatabaseDocument.setAddDate(new NSTimestamp());
theDatabaseDocument.setLastModDate(new NSTimestamp());
theDatabaseDocument.setModUser(((Session)session()).user());
theDatabaseDocument.setProject(((Session)session()).portfolioProject())
;
theDatabaseDocument.setDocumentURL(fullPath);
theDatabaseDocument.setTitle(theFileName);
theFileName = NSPathUtilities.lastPathComponent(theFileName);
// write the file
try{
FileOutputStream fileOutputStream = new FileOutputStream(outFile);
theFileData.writeToStream(fileOutputStream);
fileOutputStream.close();
ec.saveChanges();
ec.invalidateAllObjects();
}catch (IOException e){
System.out.println("Error wrtiing file: "+e);
ec.revert();
}
}else{
System.out.println("theFileName is null???!");
}
return null;
}
}
_______________________________________________
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.