jijo-paulose / gwtupload

Automatically exported from code.google.com/p/gwtupload
Other
0 stars 0 forks source link

getFileItemFactory doesn't receive the request #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I need to configure a DiskFileItemFactory using the request but I
found the method getFileItemFactory doesn't receive the request as a parameter, 
so I can't do this:

@Override
protected FileItemFactory getFileItemFactory(int requestSize) {
  // I can't get the context if I don't have the request
  return newDiskFileItemFactory(context, respository);
}

public static DiskFileItemFactory newDiskFileItemFactory
  (ServletContext context, File repository) {

  FileCleaningTracker fileCleaningTracker =
    FileCleanerCleanup.getFileCleaningTracker(context);
  DiskFileItemFactory factory = new DiskFileItemFactory(
    DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, repository);
  factory.setFileCleaningTracker(fileCleaningTracker);
  return factory;
}

I would suggest to pass the whole request object to getFileItemFactory.

Thank you!

Ferran

Original issue reported on code.google.com by ferranma...@gmail.com on 5 Jan 2012 at 9:47

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I forgot to say that getFileItemFactory() is in UploadServlet.

I also forgot to say that, although there's a workaround for the code above, 
there are times when you need the request inside that method anyway, and I am 
in that situation: I need to create an upload folder for each session, but I 
can't since I don't have access to the session inside getFileItemFactory() (I 
would if I had the request).

Thanks!

Original comment by ferranma...@gmail.com on 5 Jan 2012 at 9:52

GoogleCodeExporter commented 9 years ago

You can get the request anywhere in your code using this method:

UploadServlet.getThreadLocalRequest()

- Manolo

Original comment by manuel.carrasco.m on 23 May 2012 at 3:24