• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
FileUpload help...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FileUpload help...


  • Subject: FileUpload help...
  • From: James Cicenia <email@hidden>
  • Date: Sat, 20 Mar 2004 16:09:13 -0600

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.


  • Follow-Ups:
    • Re: FileUpload help...
      • From: James Cicenia <email@hidden>
  • Prev by Date: Multiple GlobalIDChangedNotification's since updating to 5.2.3
  • Next by Date: Re: FileUpload help...
  • Previous by thread: Re: Multiple GlobalIDChangedNotification's since updating to 5.2.3
  • Next by thread: Re: FileUpload help...
  • Index(es):
    • Date
    • Thread