Mohamed created FILEUPLOAD-303:
----------------------------------
Summary: Do not have dependency on javax.servlet
Key: FILEUPLOAD-303
URL: https://issues.apache.org/jira/browse/FILEUPLOAD-303
Project: Commons FileUpload
Issue Type: Improvement
Affects Versions: 1.4
Reporter: Mohamed
I'm trying to use FileUpload in my playframework projet to parse a
multipart/mixed request. Every thing works well if I add the *javax.servlet*
depency, which I do not use completely.
I have created my own RequestContext like:
{{public static class PlayRequestContext implements UploadContext {}}
{{ private final Http.Request request;}}
{{ private final ByteString bodyBuffer;}}
{{ public PlayRequestContext(Http.Request request) {}}
{{ this.request = request;}}
{{ bodyBuffer = request.body().asBytes();}}
{{ }}}
{{ @Override}}
{{ public String getCharacterEncoding() {}}
{{ return StandardCharsets.ISO_8859_1.displayName();}}
{{ }}}
{{ @Override}}
{{ public String getContentType() {}}
{{ return
request.getHeaders().get(Http.HeaderNames.CONTENT_TYPE).orElseThrow(unexpectedCase());}}
{{ }}}
{{ @Override}}
{{ @Deprecated}}
{{ public int getContentLength() {}}
{{ return 0;}}
{{ }}}
{{ @Override}}
{{ public InputStream getInputStream() {}}
{{ return new ByteArrayInputStream(bodyBuffer.toArray());}}
{{ }}}
{{ @Override}}
{{ public long contentLength() {}}
{{ return bodyBuffer.length();}}
{{ }}}
{{}}}
Is it possible to have another version without any dependecny to javax.servlet ?
I thinks this is a great solution for every web application, not only servlet
dependent projects.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)