[英]Transferring files between web applications running in the same Tomcat Instance
I have two web applications running in the same Tomcat Instance. 我有两个在同一个Tomcat实例中运行的Web应用程序。 In one of these applications the user will have the ability to upload files such as images and pdf files. 在这些应用程序之一中,用户将能够上载诸如图像和pdf文件之类的文件。 I would like the uploaded files to be available to the second application. 我希望上传的文件可用于第二个应用程序。
Is there a best practice for such a scenario? 这种情况有最佳实践吗? Or just a pointer to a technology would be fine. 或者只是一个指向技术的指针就可以了。
I considered using web services but wondered if it was overkill. 我考虑过使用网络服务但是想知道它是否有点过分。
Thanks Vincent 谢谢文森特
Cheap, bad answer - have both applications softlink to a shared directory. 便宜,错误的答案 - 将两个应用程序软链接到共享目录。 This has the benefit of being stupid-simple to do but has evil transactional-type issues. 这样做的好处是愚蠢简单,但有恶意的事务类型问题。 Since you say that only one application is changing the data, and the other is read-only you might be able to get away with it, as long as the second app can't observe files in a partially created state. 由于您只说一个应用程序正在更改数据,而另一个应用程序是只读的,因此只要第二个应用程序无法观察处于部分创建状态的文件,您就可以使用它。
Using a db is transactionally safe but is going to be pretty unpleasant as the files get larger. 使用db在事务上是安全的,但随着文件变大,它会非常不愉快。
I'd say it depends on how robust you need the file storage to be, and how transactional. 我会说这取决于你需要文件存储的强大程度,以及如何进行事务处理。 The simplest way would be a shared directory that's on the classpath of both apps. 最简单的方法是在两个应用程序的类路径上的共享目录。 A database would be a more robust, but more complex, solution. 数据库将是一个更强大但更复杂的解决方案。
您可以将文件推送到共享数据库中......这也允许您将元数据与它们一起存储。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.