struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Givler, Eric" <egiv...@state.pa.us>
Subject RE: get file path from FormFile
Date Wed, 17 Dec 2008 15:34:11 GMT
Would there be an issue with modifying the controller settings and setting the memFileSize
artifically low so the file is always written to disk, then gaining access to the filename
via reflection?

// create in package org.apache.struts.upload
public static String getFilePath( FormFile file ) {
   String path = null;
   Class formClass=CommonsMultipartRequestHandler.CommonsFormFile.class;
   Field fileItemField = formClass.getDeclaredField("fileItem");
   fileItemField.setAccessible(true);
   Object o = fileItemField.get( file );
   if ( o instanceof DefaultFileItem ) {
      DefaultFileItem df = (DefaultFileItem) o;
      File osFile = df.getStoreLocation();
      path = osFile.getPath();
   }
   return path;
}


-----Original Message-----
From: elyes sallem [mailto:elyes.sallem@gmail.com]
Sent: Tuesday, December 16, 2008 6:24 AM
To: Struts Users Mailing List
Subject: get file path from FormFile


Hello,
after publishing this question, i conclude that it is not possible de get back the absolute
path from FormFile but the problem is that i import a jar file, in which i call a method that
accept only path of file so what do you propose, i get the inputstream , then i create temporarly
a file and i delete it at the end or you have an other ideai?

Thanks
Regards
Elyes.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message