I'm trying to process a file upload with the multipart/form-data
facility like this:

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
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

What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
Resteasy-users mailing list

Reply via email to