[opencms-dev] Use of commons-fileupload with OpenCMS

Ivan Jelenic ivan.jelenic at nbs.yu
Thu Mar 18 12:21:02 CET 2004


R: [opencms-dev] Use of commons-fileupload with OpenCMSHi,

This works fine for me.

// Create a JSP action element
CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext, request, response);

CmsObject cms = cmsJsp.getCmsObject();

Enumeration files = cms.getRequestContext().getRequest().getFileNames();

in while loop try this:

filecontent = (byte[]) cmsJsp.getRequestContext().getRequest().getFile(fileName);

Works OK in OpenCMS 5.0.0 (RH 8, MySql 4.0.15, jdk 1.4)

Best regards,

Ivan Jelenic


  ----- Original Message ----- 
  From: Campione Aldo 
  To: opencms-dev at opencms.org 
  Sent: Thursday, March 18, 2004 9:55 AM
  Subject: R: [opencms-dev] Use of commons-fileupload with OpenCMS


  Hi Alexander, 

  I've tried your code but when I post a multipart-form data to a JSP page I get anout of memory error. 
  I've tried this under tomact and it works. 

  Can you help me ? 




  -----Messaggio originale----- 
  Da: Alexander Kandzior [mailto:alex at opencms.org] 
  Inviato: venerdì 6 febbraio 2004 12.11 
  A: opencms-dev at opencms.org 
  Oggetto: RE: [opencms-dev] Use of commons-fileupload with OpenCMS 



  In fact OpenCms 5 automatically resolves the MIME Multipart for you so you don't need to care about this in your OpenCms application. 

  You must use something like this to access the contents of binary 
  attachements: 

  CmsObject cms; 
  ... 
  Enumeration e = cms.getRequestContext().getRequest().getFileNames(); 
  while (e.hasMoreElements()) { 
     String name = (String)e.nextElement(); 
     byte[] content = cms.getRequestContext().getRequest().getFile(name); 
     // do something with content 
  } 

  Best Regards, 
  Alex. 

  Alexander Kandzior 
  Alkacon Software - The OpenCms Experts 
  http://www.alkacon.com 

  > -----Original Message----- 
  > From: opencms-dev-admin at opencms.org 
  > [mailto:opencms-dev-admin at opencms.org] On Behalf Of Ben Rometsch 
  > Sent: Friday, February 06, 2004 10:34 AM 
  > To: opencms-dev at opencms.org 
  > Subject: Re: [opencms-dev] Use of commons-fileupload with OpenCMS 
  > 
  > 
  > Sorry to bump a topic, but has anyone successfully used OpenCMS to 
  > upload files via a MIME Multipart http post? Not necessarily using 
  > fileupload? 
  > 
  > Thanks, 
  > Ben 
  > 
  > Ben Rometsch wrote: 
  > 
  > > Hi There, 
  > > 
  > > I cannot get the jakarta-commons file-upload API to work under 
  > > openCMS. 
  > > 
  > > http://jakarta.apache.org/commons/fileupload/ 
  > > 
  > > According to fileupload, the multi-part form request that 
  > is generated 
  > > by the browser when trying to upload a file contains NO name-value 
  > > pairs. I have run identical code in a pure tomcat/jsp 
  > environment and 
  > > it works fine. 
  > > 
  > > Has anyone successfully used file-upload with OpenCMS? Or is there 
  > > another standard way of handling multipart forms? 
  > > 
  > > Thanks, 
  > > Ben 
  > > 
  > 
  > -- 
  > ----== Solid State Group ==---- 
  > Web     www.solidstategroup.com 
  > Email   ben at solidstategroup.com 
  > MSN     benrometsch at hotmail.com 
  > 
  > _______________________________________________ 
  > This mail is send to you from the opencms-dev mailing list 
  > To change your list options, or to unsubscribe from the list, 
  > please visit http://mail.opencms.org/mailman/listinfo/opencms-dev 
  > 
  > 

  _______________________________________________ 
  This mail is send to you from the opencms-dev mailing list 
  To change your list options, or to unsubscribe from the list, please visit http://mail.opencms.org/mailman/listinfo/opencms-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040318/cdde136b/attachment.htm>


More information about the opencms-dev mailing list