jsp file upload location - java

hi i am uploading my images using the
String filePath = context.getRealPath("/")+"/Library/";
all of the images are get to saved in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
when i list the files in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
from terminal i can see the images that were uploaded. but if i list the files in
.../workspace/MyProj/Library/
i cannot see them. also from eclipse (inside project explorer)
MyProj
->Library
i cannot see the images uploaded. then i thought probably that location is kind of temp location, and restarted my computer. but uploaded images are still in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
but through eclipse they are not visible, doing file->refresh also did not help. my questions are follows will the uploaded images stay in this location
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
and why i cannot see them from eclipse? if it is possible can you show me how to save them directly in
.../workspace/MyProj/Library/
thanks!

You can't see the images because eclipse has deployed your webapp to a server and your images are being uploaded to the server.
You can save them directly to your workspace by using:
System.getEnv("user.home")+"/workspace/MyProj/Library/"
instead of:
context.getRealPath("/")+"/Library/";

Related

Spring boot doesn't serve some of the images from the src/main/resources/public directory

I'm trying to develop a small webapp, for learning purpose, with spring boot,thymeleaf and mysql.I'm using Eclipse IDE
Users can upload images to the app, My Controller class store the images in the src/main/resources/public/images folder and it's URL in the db.
The problem is, Eventhough the images saved by the controller exists in the src/main/resources/public/images directory, They are not directly visible in the public directory from Eclipse, as a result when referred from the served webpages, those images do not show up. Some of the images I manually copy pasted into the public/images folder within the Eclipse .(To do that actually I had to move images to another directory as it's not possible to copy from and paste into the same folder)
Those images are rendered in the served web pages.. The other images saved by the controller, even though they exists in the same directory ,they are not directly visible from Eclipse IDE and they are't rendered in the served pages.
This is Directory's view within the eclipse and all these images are rendered correctly in the served webpages
This is the same directorie's view from the file system, and it contains many images that are not directly visible from eclipse.
And when I include these images in the webpages , they are'nt rendered even though they reside in the exact same folder as other images..
How to get around this issue?
When you run a spring boot or normal spring project using IDE it will bundle everything inside a war and then it serves that bundle so without restarting the server or re-running the application Eclipse doesn't loads the images.
This has nothing to do with spring boot.It is because of the Eclipse IDE as you know if you paste one image inside the folder directory but images wont load without restarting the server or re-running the application.
My recommendation would be to store images on any directory other than your deployed folder directory and access them without any issues.
I have done this inside tomcat folder without any issue.

Making folders of images available in the project

I need set of images in jpg format to be in this specific folder.
path = getFilesDir() + "/imagefiles/";
After root my mobile phone, I manage to find the specific folder. The location is /data/data/*packagename/files/imagesfile/*png images.
I can copy the image manually into the folder but i want to deploy a project that already has the image in it.
I have tried several solution but none really works for me. Please help me.
I can copy the image manually into the folder but i want to deploy a project that already has the image in it
It is not possible for you to create an app that automatically has files in getFilesDir() immediately upon installation.
What is possible is for you to put images there on the first run of your app. Those images could be:
downloaded from the Internet
packaged in assets/ in the project, then copied into your desired location using AssetManager and open()
packaged as raw resources in the project, then copied into your desired location using Resources and openRawResource()
etc.

How to download video from url and hide/secure this video from other apps and Gallery

One part of my current project is downloading Videos from URL then saving to SDCard. But the problem is all of saved videos in sdcard is displayed in android gallery page. What I want is "I don't want all of my saved vidoes in android gallery."
Create a .nomedia file inside the folder you don't want to be tracked by the MediaScanner. Maybe you'll need to rename the folder name after creating the file, since there is a bug that the MediaScanner (in some versions of android, not sure which one) fails to forget already-indexed files when it encounters a .nomedia file.

Unable to find the file saved in WebContent

I'm using Glassfish 3 and Eclipse as my IDE.
In the application, I developed a small file upload feature which saves the files in WebContent. I know it is a bad practice because I'm loosing all the files on every redeploy and so on.
The file is saved at:
E:\java\server\Glassfish3\glassfish\domains\domain1\eclipseApps\myApp\upload\story\79.png
Than I try to list render that picture in my .xhtml file using:
<img src = "upload/story/79.png" />
Weirdly enough, on the Servlet side (or ManagedBean in my case) when deciding if the image exists or notit all looks fine and the image is found on the disk. However, in the browser the image is not displayed because it fails to load the given URL.
How can I solve this problem?

how to download folder containing files(pdf,png etc) from php server in android

i want to download folder containing files like pdf,jpg,png etc from web services.I have written a application that can download pdf,png file.But i want to download folder containing several files. So my question is- is it possible to download folder and if yes then how can i download folder from server in android. thank you
If you can download one file, why wouldn't you be able to download several? Create the folder on Android, queue the files and start the next download when the current is finished, filling the folder. Also Android supports ZIP, so that might be your best call.
Folder is nothing but an FILE but a different type of file. Once you get the folder you can list down the files in it. You already have URL with the folder, u just need to append the URL of the folder to the files in it and download them one by one.

Categories