简体   繁体   English

在Tomcat的哪里上传文件?

[英]Where to upload files in Tomcat?

I have a web application developed using Servlet and JSP, we will be hosting this in Daily Razor Privat Tomcat Hosting soon. 我有一个使用Servlet和JSP开发的Web应用程序,我们将很快在Daily Razor Privat Tomcat Hosting中托管它

But, now we have a problem. 但是,现在我们有一个问题。 We have a form where the users can upload files to the server, files like images and PDF's. 我们有一个表格,用户可以将文件,图像和PDF等文件上传到服务器。 Now, we are not sure in which place we should save these files in server. 现在,我们不确定应将这些文件保存在服务器中的哪个位置。 I have seen lot of Stackoverflow answers telling the user to use the path like "C:/Upload/.." but this is a real product, so this is not gonna work. 我已经看到很多Stackoverflow答案,它们告诉用户使用“ C:/ Upload / ..”之类的路径,但这是一个真实的产品,因此将无法正常工作。

I contacted the hosting company about this matter and all they said is they will give the FTP logging details once I purchased the system, no word about where to upload the files. 我与托管公司联系了此事,他们说的是,一旦我购买了系统,他们将提供FTP日志记录详细信息,没有任何关于将文件上传到何处的消息。

I also thought about uploading to Amazon S3, but we have to create folders "dynamically" for each user and subfolders for their uploaded content, therefor I am not so sure about S3. 我也曾考虑过上传到Amazon S3,但是我们必须为每个用户及其子文件夹的上传内容“动态”创建文件夹,因此我不太确定S3。 Apart from that, I believe S3 will drain my wallet. 除此之外,我相信S3会耗尽我的钱包。

Any advice about the upload location in tomcat or an alternate will be really appreciated. 关于tomcat或备用位置中的上传位置的任何建议将不胜感激。

But, now we have a problem. 但是,现在我们有一个问题。 We have a form where the users can upload files to the server, files like images and PDF's. 我们有一个表格,用户可以将文件,图像和PDF等文件上传到服务器。 Now, we are not sure in which place we should save these files in server. 现在,我们不确定应将这些文件保存在服务器中的哪个位置。

If you're talking about long-term storage then there's no correct answer here. 如果您正在谈论长期存储,那么这里没有正确的答案。 You'd just need to find a place on the server where your Tomcat user has permissions to write and configure the application to put them there. 您只需要在服务器上找到Tomcat用户有权编写和配置应用程序以将其放置在其中的位置。

I contacted the hosting company about this matter and all they said is they will give the FTP logging details once I purchased the system, no word about where to upload the files. 我与托管公司联系了此事,他们说的是,一旦我购买了系统,他们将提供FTP日志记录详细信息,没有任何关于将文件上传到何处的消息。

Once you have FTP details, you should be able to connect to the server and look at the file system. 一旦有了FTP详细信息,就应该能够连接到服务器并查看文件系统。 Presumably this would allow you to see the path where your application will be deployed. 据推测,这将使您看到将应用程序部署的路径。 From there, it's just a matter of picking a location where you'd want to save the files. 从那里开始,只需选择要保存文件的位置即可。

I'm not familiar with that hosting provider, so I can't really same more. 我对那个托管服务提供商不熟悉,所以我再也无法做到了。

I also thought about uploading to Amazon S3, but we have to create folders "dynamically" for each user and subfolders for their uploaded content, therefor I am not so sure about S3. 我也曾考虑过上传到Amazon S3,但是我们必须为每个用户及其子文件夹的上传内容“动态”创建文件夹,因此我不太确定S3。 Apart from that, I believe S3 will drain my wallet. 除此之外,我相信S3会耗尽我的钱包。

This can also be a good option, depending on your needs. 根据您的需要,这也是一个不错的选择。 Price is definitely something to evaluate. 价格绝对是要评估的东西。 Demand and bandwidth on your hosting environment are others. 托管环境的需求和带宽是其他因素。 If you have high demand on these resources, putting them on AWS will take the load of your server and not eat up the bandwidth allocation from your hosting provider. 如果您对这些资源有很高的要求,则将它们放在AWS上将负担服务器的负载,而不会占用托管提供商的带宽分配。

You could also store your uploads in a database. 您也可以将上传的内容存储在数据库中。 I'm not personally a fan of this, but some people do it and I hear it works fine for them. 我个人并不喜欢此功能,但是有些人这样做了,我听说它对他们很有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM