Downloading multipart file in AEM Sling filter - how?
Hi, I am uploading assets to AEM's servlet, but before the file reaches servlet, I want to intercept it with a filter and scan it.
All details aside, I am unable to extract file from ServletRequest.
Here is my filter:
@Component
@SlingServletFilter(scope = {SlingServletFilterScope.REQUEST},
pattern = ".*createasset.html",
methods = {"POST"})
public class UploadFileFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response;
//try to download multipart file...
chain.doFilter(request, slingResponse);
}
@Override
public void destroy() {
}
}
I can't read input stream directly in filter, because it has already been read.
I have tried solution from this post:
But request.getRequestParameterMap() always return empty map. Is it because I try to access parameters in a filter, not a servlet?
Do you know any working way to download multipart file in a filter?