Hello Thiago, I have implemented a Requestfilter as you wrote here before! But I still encounter major issues when retrieving the file as an Array of of Bytes, since thats how we can put it on a Blob(googles Binary Large Object).
The problem here is that the request Parameter in is not an implementation of the HttpServletRequest! Is there another way of retrieving the posted file as a byte of arrays out of the *Request* parameter? Or How can I else retrieve the original HttpServletRequest in Tapestry5? here is my example: *public class MyUploadFilter implements RequestFilter {* *private final Logger log;* *private final String urlPath = "/personal/addproduct.upload";* *private static final String IMAGE = "imageField";* *@Inject* *private MyFileUploadService uploadService;* * * *public MyUploadFilter(Logger log) {* *this.log = log;* *}* * * *@Override* *public boolean service(Request request, Response response, RequestHandler handler) throws IOException {* *log.info("PATH = " + request.getPath());* *if (urlPath.equalsIgnoreCase(request.getPath())) {* *log.info("################# GOOOOOO ############");* * * *request.getParameterNames();* *for (String param : request.getParameterNames()) {* *System.out.println(" # " + param);* *if(IMAGE.equalsIgnoreCase(param)){* *Object obj=request.getAttribute(param);* *System.out.println(" # " + obj.getClass());* *System.out.println(" # " + obj.getClass().getCanonicalName());* ** *}* *}* ** *try* *{* * * *ServletFileUpload upload = new ServletFileUpload(); * *FileItemIterator iterator = upload.getItemIterator(request);* *FileItemStream item = iterator.next();* *InputStream stream = item.openStream();* *String filename = item.getName();* *Blob content = new Blob(IOUtils.toByteArray(stream));* * * *if (filename.substring(filename.length() - 3,filename.length()).equalsIgnoreCase("JPG"))* *{* *PersistenceManager pm = PMF.get().getPersistenceManager();* *Image doc = new Image(filename, content);* *pm.makePersistent(doc);* *pm.close();* *}* *}* *catch (Exception ex) {* *log.error(ex.getMessage());* *return false;* *}* * * *}* *return handler.service(request, response);* *}* *}* On 12 March 2011 20:47, Thiago H. de Paula Figueiredo <thiag...@gmail.com>wrote: > On Sat, 12 Mar 2011 15:29:21 -0300, Fernando Benjamin < > fernandobenja...@gmail.com> wrote: > > Fellow tapestry developers, >> > > Hi! > > > I need to upload an image to a certain url, but I can't use any Normal >> file upload mechanism because I am running Tapestry5 on GAE! >> > > So you want to write an application that receives a file upload, right? > > > Well I don't know from which Class my Filter should implement. >> > > I'd implement RequestFilter. Being it part of Tapestry, you don't need to > add anything to web.xml. You just need to contribute your implementation to > the RequestHandler service. This is done by adding a method like this in > your AppModule: > > public void contributeRequestHandler(OrderedConfiguration<RequestFilter> > configuration) { > configuration.addInstance("YourRequestFilterClassName", > YourRequestFilterClass.class, "before:*"); > > } > > Where can I found more info about the request life-cycle in Tapestry5? >> > > http://tapestry.apache.org/request-processing.html. Don't be scared: you > don't need to know even 10% of it to use Tapestry very well. The diagram at > the end of that page is just showing every single thing that can take part > of processing a request, including many internal classes you never touch or > use. > > *What I would like to do is:* >> >> 1-Implement a filter with some functionality >> 2- Inject the filter it at the right place with TapestryIOC. >> 3-Map an url to this filter >> > > Implementing a RequestFilter, you don't need to map an URL to it. Inside > the RequestFilter's service method, you use request.getPath() to know if > that request's URL is handled by your filter. If yes, process it and return > true. If not, return service(request, response, handler). > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >