Ganesh2
Ganesh2

Reputation: 176

File storage for Java based web application

I'm in the processing of designing a Java based web application (Spring based to be specific). One of the key requirement is that, this application has to accept many files of various formats (pdf, jpeg, dwg, png etc.) uploaded by the user. Also, to be able to download back to user's local computer. There will be thousands of files being uploaded/downloaded.

I am thinking of two approaches:

  1. Upload the documents to the same box where server is running. Mostly all the documents will be uploaded to, and downloaded from box where Tomcat is running. I'm worried that, as the documents grow in number, this may impact overall performance.

  2. Upload/download documents to another server dedicated for storing/retrieving of documents.

If 2nd approach is taken, how Spring application can upload/download files to/from remote server? Or which approach is being used in the similar applications.

Or could you suggest any other optimal way of handling this requirement.

Thanks in advance. Ganesh

Upvotes: 1

Views: 4429

Answers (3)

Yoosefi
Yoosefi

Reputation: 1

I recommend you using a JCR like Apache Sling or Apache Jackrabbit.

Apache Sling™ is a framework for RESTful web-applications based on an extensible content tree with the following feautures:

  • Content resolution that maps a request URL to a content node in the content repository
  • Servlet resolution that maps a content node and a request method to a Servlet handling the request
  • Default servlets supporting WebDAV, content creation from web forms and JSON representation
  • A Javascript client library, allowing access to the content repository through AJAX
  • Support for server-side scripting with Javascript, JSP, Ruby, Velocity and Scala
  • OSGi-based extensibility through Apache Felix – the Felix Web Console was originally developed by the Apache Sling project

Upvotes: -2

Sok Pomaranczowy
Sok Pomaranczowy

Reputation: 1023

Have you thought about using a DB. You could store those files as BLOBs. Here is a tutorial for this: link

"This tutorial walks you through the steps of building an interesting Spring MVC web application that allows the user to upload files from her computer to the server. The files are stored in database using Hibernate."

As to two approaches you consider:

Either way you will have to manage those files, back them up and check if there is enough space to store more files. Also this may cause some security issues as you accept all files.

Upvotes: 1

FrobberOfBits
FrobberOfBits

Reputation: 18002

Many modern applications built like this are going to use an external storage system like Amazon S3 to store these files, which buys you all kinds of nice features - high availability for downloads, an effectively unlimited pool of disk space, data replication, and so on.

There's a tutorial available for integrating spring with Amazon S3. You should check that out. Regardless of whether you choose S3 or something else, the approach will be similar.

Upvotes: 2

Related Questions