I am using quarkus framework for java application.I have created 2 rest apis for consuming file data.
@POST
@Path("file")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFile(byte[] fileData) {
System.out.println("Received file of size = " + fileData.length);
String s = new String(fileData);
return Response.ok().build();
}
@POST
@Path("files")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public void uploadFile(@MultipartForm FormData fileData) throws IOException {
System.out.println("Received file of size = ");
System.out.println(fileData.file.length());
return Response.ok().build();
}
FormData class looks like this
public class FormData {
@FormParam("file")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
public File file;
}
While both of these rest endpoint works fine for small files. But if i upload file as big as 700MB first endpoint fails with OOM issue while file upload with multipart-form succeed. Can someone explain how memory is managed in case of multipart-form upload?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…