Additional Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Likes
194
To be honest, this was the hard part. I'd never done this before but I knew it was theoretically possible. I dug around SDN and found some code snippets, but it took a while before I could put it together in a manner that made sense.
Here's the magic bits:
this.propertyMap = new MutablePropertyMap();
...
this.loggedOnUser = (IUser) request.getUser().getUser(); //figuring out to typecast this was a drag!;
Event event = context.getCurrentEvent();
...
// grab the file using java.fileinputstream... remembering to use the jsp file context (headache)
FileUpload fileUpload = (FileUpload) context.getComponentForId("fileUpload");
...
if (this.loggedOnUser.isAuthenticated()) {
rContext = new ResourceContext(this.loggedOnUser);
RID aRid = new RID(this.repository); // remember that the repository is case sensitive
try {
IResourceFactory aResourceFactory = ResourceFactory.getInstance();
aCollection = (ICollection) aResourceFactory.getResource(aRid, rContext);
IContent aContent = new Content(this.sourceFileInput, this.mimetype, -1L);
if (aCollection != null) {
aResource = aCollection.createResource(this.resource, this.propertyMap, aContent);
1 Comment