View source | View content page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Show collection (0 pages)
Collections help

Search

Projects:Process File upload Reference/Performance

Uploaded file storage

In this project, we're using Apache commons ServletFileUpload and DiskFileItemFactory classes to retrieve the received file from the request on the server side. These classes policy is to save the uploaded file to disk if its size is above a certain threshold (default 10KB) [1]

Server-side file validation

One of our main concerns in this project is to avoid loading large files in memory as much as possible. For this reason we implemented both server and client side validation to check that the uploaded file is not too big.

For the server-side validation, we use the file.getSize() function provided by Apache commons's in the FileItem object. This call internally calls Java's File.length(), which uses a FileSystem call to retrieve this info. In the following graph we show the Tomcat Openbravo process while we run a Process that loads two 1.3GB files after performing a GC call. As we can see, the parameter processing has no impact in the heap.

Screenshot from 2022-01-03 10-17-11.png

Performance on File read

Performance was tested by creating a Process that reads a file line by line using the following code:

try {
  InputStream stream = (InputStream) ((Map<String, Object>) parameters.get("myfile"))
            .get("content");
  BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
  
  while (reader.ready()) {
    String line = reader.readLine();
  }
} catch (IOException e) {
  log.error("Failed reading file");
}

And tested it by starting Tomcat, performing a GC call and then executing the process with a large file (~1GB) with the following result:

Screenshot from 2022-01-07 09-52-35.png

Retrieved from "http://wiki.openbravo.com/wiki/Projects:Process_File_upload_Reference/Performance"

This page has been accessed 45 times. This page was last modified on 7 January 2022, at 09:02. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.