Pergunta

When a file is submitted to my server using a multipart/form-data POST, is it possible to retrieve only the content of the file from the HttpServletRequest object? The request.getInputStream() shows some headers included at the beginning and then ------WebKitFormBoundary... at the end.

Can I get just the file data without having to parse the input stream and extract it?

Foi útil?

Solução

You could annotate your servlet with @MultipartConfig, then you can use HttpServletRequest#getParts() to get the individual parts.

This is available starting from Servlet 3.0. If for some reason you're stuck on an older version of Java Servlets, you may choose to use Apache Commons File Upload.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top