|
From: ujay68 <uj...@gm...> - 2011-05-18 13:36:34
|
Hi,
I'm trying to process a file upload with the multipart/form-data
facility like this:
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Object upload(MultipartFormDataInput formData) throws IOException {
InputPart part = formData.getFormDataMap().get("file").get(0); //
"file" is the name of the browser's input field
DataSource dataSource = part.getBody(new GenericType<DataSource>() { });
InputStream in = dataSource.getInputStream();
// ... read from input stream
return Response.ok().build();
}
The data source has the correct content type, so the setup seems to be
generally right.
But when I read from the input stream, I get only 1024 bytes even if
the uploaded file is longer.
Just a guess: The InputPart is implemented by
org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.PartImpl.
When I look into that PartImpl's part.bodyPart.body with a debugger,
it looks like there is some storage provider behind the scenes
implemented by a
org.apache.james.mime4j.storage.ThresholdStorageProvider. That
provider has a head of 1024 bytes and a tail with the rest of the
bytes. That tail seems to be lost. Could be something else entirely,
of course.
I'm using v2.1.0.GA.
Is this a bug? Am I doing something wrong here? Does someone know a
workaround (apart from parsing with my own code)?
Thanks, Jay
|