[英]How to store files in a java web application?
This is a design related question. 这是一个与设计有关的问题。
I have a java web application(connected to MySQL database) running on tomcat. 我在tomcat上运行了一个Java Web应用程序(已连接到MySQL数据库)。 It runs on both linux and windows machines separately(as of now).
它分别在linux和Windows机器上运行(到目前为止)。 I should store files which come as input, whose size varies from 500 KB to 100 MB (max).
我应该存储作为输入的文件,其大小从500 KB到100 MB(最大)不等。 The use of these files is to parse them and get required data.
这些文件的用途是解析它们并获取所需的数据。 I can use the 'blob' in database schema to store files, access them to generate the required output and store them in MySQL db.
我可以在数据库模式中使用“ blob”来存储文件,访问它们以生成所需的输出,并将它们存储在MySQL数据库中。 Else, I can use file system to store the files in the windows or linux filesystem and use them to extract the data, store it in MySQL db.
否则,我可以使用文件系统将文件存储在Windows或linux文件系统中,并使用它们来提取数据,并将其存储在MySQL数据库中。 In any month I will be saving close to 200 files of varying length.
在任何月份中,我将保存将近200个不同长度的文件。 I am unable to decide which implementation to choose?
我无法决定选择哪种实现?
The following are some pros and cons which I came up comparing filesystem vs database. 以下是我比较文件系统与数据库的一些优缺点。
File-System: 文件系统:
MySQL: MySQL的:
Read https://dba.stackexchange.com/questions/2445/files-in-the-database-or-not 阅读https://dba.stackexchange.com/questions/2445/files-in-the-database-or-not
This is a good article too: http://www.revsys.com/blog/2012/may/01/three-things-you-should-never-put-your-database/ 这也是一篇很好的文章: http : //www.revsys.com/blog/2012/may/01/three-things-you-should-never-put-your-database/
I think it depends on how much read/write activity you have. 我认为这取决于您有多少读/写活动。 I'm personally in favor of keeping these files in the database specially if you have a fast database like MongoDB.
我个人赞成将这些文件保留在数据库中,特别是如果您拥有像MongoDB这样的快速数据库。 You put a limitation of 100MG so it wouldn't get that large either.
您设置了100MG的限制,因此也不会太大。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.