Multipart File Upload on Google Appengine using jersey-1.7

前端 未结 5 863
长情又很酷
长情又很酷 2020-11-30 09:11

I wrote an application on Google Appengine with Jersey to handle simple file uploading. This works fine when it was on jersey 1.2. In the later versions (current 1.7) @FormD

5条回答
  •  被撕碎了的回忆
    2020-11-30 09:41

    For files beyond its default size, multipart will create a temporary file. To avoid this — creating a file is impossible on gae — you can create a jersey-multipart-config.properties file in the project's resources folder and add this line to it:

    bufferThreshold = -1
    

    Then, the code is the one you gave:

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Response post(@FormDataParam("file") InputStream stream, @FormDataParam("file") FormDataContentDisposition disposition) throws IOException {
      post(file, disposition.getFileName());
      return Response.ok().build();
    }
    

提交回复
热议问题