简体   繁体   English

我应该将用户上传的图像保存在哪里? Java Web应用程序

[英]Where should i save my images that user uploads? java web application

I am saving the image at this location :- 我将图像保存在此位置:-

private static String photoGalleryPath = "/Common/PhotoGallery/";

I save the image at context.getRealPath(photoGalleryPath) 我将图像保存在context.getRealPath(photoGalleryPath)

Everything works fine, but when i clean and build my project. 一切正常,但是当我清理并构建项目时。 The whole folder of PhotoGallery gets deleted. PhotoGallery的整个文件夹将被删除。 This looks very funny to me :). 这对我来说看起来很有趣:)。 Why does it delete my whole folder everytime? 为什么每次都删除我的整个文件夹? And what more should i do to tell the extra smart Glassfish to not to delete my folders? 而且我该怎么做才能告诉额外的智能Glassfish不要删除我的文件夹?

You probably should not be storing data within your servlet's webContent directory because (as you observe) redeployment of the WAR may blow it away. 您可能不应该将数据存储在servlet的webContent目录中,因为(如您所观察到的)重新部署WAR可能会使其失效。

Instead, create a directory somewhere else to hold the images; 而是在其他位置创建一个目录来保存图像。 eg /var/yourProject/PhotoGallery/ Alternatively save the images in some kind of database / filestore. 例如/var/yourProject/PhotoGallery/或者将图像保存在某种数据库/文件存储中。

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

相关问题 在Spring MVC Hibernate应用程序中,应该将用户图像保存在哪里? - In a Spring MVC Hibernate application, where should I save user images? 我应该把我上传的图像放在java应用程序的服务器上? - Where should i put my uploaded images on server in java application? 在 java web 应用程序中,我应该在哪里存储用户照片? - In java web application, where should I store users photos? Java Web应用程序国际化:大文本应该存储在哪里? - Java Web Application Internationalization: Where should I store big texts? 我应该在哪里(确切地)在我的Java EE应用程序中使用同步 - Where (exactly) should i use synchronization in my Java EE application 是否应该在Java Web应用程序中为此创建模型和DAO? - Should I create a Model & DAO for this in my Java web application? 我应该在哪里存储我的图像? - Where should I store my images? 我应该将Java应用程序的图像放在哪里? - Where should I put the images for the Java app? 在Spring MVC应用程序中将用户上传的内容存储在哪里? - Where to store user uploads in spring mvc application? 我应该在哪里存储我的程序在Java中使用的图像(和其他文件)? - Where should I store images (and other files) to be used by my program in Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM