I have deployed the war into tomcat 7 Openshift . Everything is fine and its running .Myappp Here is my mapped web application.
I am storing images in the dir webapps->docs->images
But When I upload the image (with UI) it doesnt appear on site and I cant even find where images are stored (I connected using FTP -filezilla )
Where my deployed war file stored ? Do I need to make any changes in my code so to upload in proper dir of Openshift??
Thanks in advance
You should use your OPENSHIFT_DATA_DIR (~/app-root/data) to store uploaded images. However, using Java this presents some challenges. I would recommend that you read through this article (https://forums.openshift.com/how-to-upload-and-serve-files-using-java-servlets-on-openshift), it should help you with dealing with user uploaded images.
Related
I'm trying to upload a number of website directories to a server with spring, and generate links so i can view them later on. I realized i can't put web directories right into the standard resources folder because that's inside the web archive, and if i try to use an external resources folder it just gets shuffled into the web archive when the app is built. My other possible approach would be to make a separate downloads servlet, but that seems like it wouldn't work because if it only downloads the index.html file from the site, it wouldn't also show the other files that the site depends on, which is not what i want.
I understand that relying on system paths is not very portable but probably this program will only run on at most 3 or 4 linux computers so I could just set up the file path on them manually if i can't just do it from within the java program itself.
I have a JAVA application that needs to store profile pictures that user uploaded.
My project already finish and works fine.
//in my LOCALHOST i use this path:
File file = new File("C:/myProject/uploads/profile_images");
So, now I want deploy this project, i'm using jelastic environment and the question is:
Where should these files (pictures) be stored in our Jelastic ?
I already tried in the same code but doens't work.
I already tried save the files in WebContent folder, work, but when I expand a new .war file, the files that user has uploaded are overrides.
I read about save files in mySql, is a good idea?
Thank for your atention.
Local filesystem is persistent, but make sure to define in 'volumes' if your node has it to ensure files are kept during image redeploy. You can also use Jelastic storage node, but only worthwhile if you're using multiple application nodes.
See https://docs.jelastic.com/docker-volumes for details about how to use the volumes feature - if your node doesn't have this feature it is not based on Docker (not all node types were converted yet). In that case you can write to the filesystem without any risk of those files going missing (i.e. it will behave the same as a dedicated server or your local dev machine).
I have the following problem: I haven an application which uses SpringMVC and Hibernate, and when the user uploads an image it stores it in the /resources/img folder, but when I have to do another deploy I complile my source code into a war, and then I deploy it again, overwriting the image that the user has just upload becose the whole folder is in the war. I don't know how it works, but the problem is that the user lose every image that he has uploaded when I deploy the app again.
Does anyone know the best way to solve this? I know that save the image in the database is not a good practice, so I want to avoid that.
Thank you!
I am working on a J2EE application in which I need to save user's pictures. my question is where should I save these pictures ? knowing that I want to use a relative path .
NB : I am using glassfish as server .
The best practice here is to save the image inside your web application under web content (make a separate folder) , in this way you will be able to render images in other browsers also (not just in eclipse default's)
and you need to save the complete path of the image into database.
eg : e:\workspace\projectname\webcontent\pic\image.jpg
NB : never store image in database
I uploaded files to the server using BLOB db type on play framework. In the application.conf file I have
attachments.path=home/dotcloud/uploads
But I couldn't find the files on the server.
The issue is that if I restart my www service, then I lose all my files, I only have the db records.
I believe that there are two issues in here. First your path lack a initial '/' to be a full path (I'm assuming that was your intention):
attachments.path=/home/dotcloud/uploads
Second, I'm not sure that your Play server will have rights to write to that folder, as it's outside the application context path. Default folder is local to the application and Play can write it, not so sure about other folders though. You should double check that.