2

I'm running in to an issue when trying to upload a file to a spring/jackson webservice. My service description is below:

@POST
@Path("/foo/{someID}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
        @FormDataParam("file") InputStream uploadedInputStream,
        @FormDataParam("file") com.sun.jersey.core.header.FormDataContentDisposition fileDetail,
        @PathParam("someID") Long supplierID)
{
}

The error I'm getting is:

The request sent by the client was syntactically incorrect.

Here are my headers pulled from Chrome for one that isn't working.

Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:879585
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary1VA1IfWOdVmZqk49
Cookie:SPRING_SECURITY_REMEMBER_ME_COOKIE=COOKIE_HERE
Host:localhost:8081
Origin:chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
Request Payload
------WebKitFormBoundary1VA1IfWOdVmZqk49
Content-Disposition: form-data; name="file"; filename="Chrysanthemum.jpg"
Content-Type: image/jpeg


------WebKitFormBoundary1VA1IfWOdVmZqk49--

Found out that it's not the content type, but the content size. At 9377 bytes it breaks, but at 9375 bytes it works. Unfortunately that doesn't seem to coincide with any documented limit (default or otherwise) in Tomcat, Spring, or Jersey, so I'm stuck as to what would be causing this.

4

2 回答 2

1

So I eventually found out what this was. The issue was that we exceeded the amount of space that tomcat would allocate in memory for the file for this transfer. It then tried to write the file out to temp space but the temp space prevented writes from the tomcat application. Once this was fixed then everything started working as expected. So if you run in to something similar check where tomcat writes it's temp files (C:\Program Files\Apache Software Foundation\Tomcat 7.0\temp for my example) and make sure it has the correct access to do write to this directory.

于 2013-07-18T02:13:37.290 回答
1

My problem wasn't length of post related - I simply was sending a JSON object that had properties that weren't present in the POJO on the other end.

于 2013-10-27T22:39:03.467 回答