Please spare me if my question sound naive, but I have a doubt regarding managing a large no. of images uploaded by user, for an instance I have a web application which allows user to upload multiple images which are stored on disk (lets say /opt/images/multiple_folders_containing_multiple_images), but when I refer it on my HTML code then the images are not loaded.
Can anyone please suggest what I'm missing or doing wrong.
I've came across some possible solutions:-
1) Simplest way to serve static data from outside the application server in a Java web application
2) Introduce a Apache server and host your image folder and then refer the static content, the benefit of using this is that, it is scale-able and can be easily migrated.
If anyone have better solution, then please do post.
Related
I am currently developing a web application for a local company using Java, Spring Framework and MySQL no ORM. This is the first time I have dealt with uploading files.
My situation is that part of the system allows an admin user to upload images for store items.
currently all my resources such as images are organised and located like such: (located in the unpacked .war at the ROOT of my tomcat server)
/resources/img/items/
/resources/img/items/thumbnails
However I have come to the realisation that when the web app is deployed and a user uploads an image, it will be stored in the above locations. Therefore when I redeploy, the uploaded images will not be present.
My question, is there a better location to store these images? Or am I missing something. I have been researching for the past couple of hours and seem to have not gotten far. I'd be very thankful to anyone who could offer some knowledge. Thanks in advance.
There are many options where to store files.
MySQL: Store them in your MySQL database using the BLOB datatype. The advantage is that you have all your persistent data in a single location which is handy when doing backups. On the other hand, image data may bloat your database quickly.
In the file system: Store them in the file system, e.g. in /var/yourapp/uploaded-images. You need to tell your application about where to find that directory. There are many ways to do this:
create a configuration table in your MYSQL and put the folder there
let your web container/server provide that variable
via JNDI service
...
Make sure you have a rescue plan when that disk crashes with tons of data ^^
Separate Database
Since image data may bloat your database quickly, you may want to use another database for your images. In many architectures binary data are separated from the "real" business data.
I guess these are the typical solutions to your problem. However, there is no standard recommendation what to choose for it depends on facts you didn't provide, or cannot provide at the moment:
Are the images business-critical (technical drawings)
Size of the images (8kB JPEG vs. 200 MB raw image)
What are the demands of your users and who are they (SaaS vs small intranet application)
... many more ;)
Whatever you choose, it is better than storing files in the exploded war :)
I am planning to develop e-commerce application with tomcat server. Kindly suggest where i need to save images and how to serve images to applicaiton.
you can save images in your project path,
you can save them in your local machine,
you can save them in the database too.
i prefer to save the imagepath in database and then load the image to the application by getting the image from that location.
there are somany ways that you can extract image from a location
you have to be fammiliar with filereading , bufferedimage ,filewriting using java base64 encoding and decoding technologies so that you can send an image in a string format.
you should start coding the application and then post the problems that you've got
Since this question is highly opinion based so here comes my opinion. If I were you developing an ecommerce application, I would rather put my images on cdn than keeping them in my application since ecommerce applications are supposed to have a lot of images and it can weigh a lot while you package your application. So, it's better to have images at separate location (recommended cdn since they have their own caching) to make efficient use of them.
I am a C# developer who recently decided to venture into the mobile dev world specifically android dev using java. It has been a smooth ride until now. While I'm usually able to follow the tutorials on the android developers site and other sites easily, uploading an image/video to the app engine blobstore or cloud storage seems to be a bit over my head. I cant seem to wrap my head around the process.
I have already done the necessary steps to get my app running on app engine. I am able to register devices and save basic entities to the cloud but I cant seem to get any of the tutorials to work form me.
Basically my app allows users to take images or videos and then have them posted to my back end as part of a file sharing type of game.
I am not asking for someone to give me code that can accomplish this, instead pointing me to a very thorough tutorial would be great!
1.I need understand the role of a servlet (most examples use this for uploading to blobstore)
2.Where should the servlet reside?
3.Is there another way to do this without using a .jsp page for the file uploading ?
4. I have set up the app engine back end for my project including endpoints. Is there a way to send the images/video that way to the server and still be able to retrieve a serving url to fetch the image/video later?
I have been stuck on this for a week now and I'm getting quite discouraged as I cannot seem to adapt any of the tutorials that I have read to suite my needs. There are a few dark spots in my mind where the entire process is concerned. Since I am not familiar with java, servlets etc I'm stumbling in the dark and I just need a lamp to light my path. I think i'm just a step or two away.
BTW I have looked at these questions and tried the code suggested to no avail before deciding to post my own.
Upload to Appengine Blobstore in Android
BlobStore vs Cloud Storage for storing user uploaded images
Upload image from Android to Google Cloud Storage or Google App Engine Blobstore
Please help!
NOTE: I don't have an interface where the user gets to choose the image/video as it is to be taken directly from the camera and sent to the server(not sure that makes a difference).
You need to do a lot more reading. First understand servlets in general. Then learn how to use the blobstore or cloud storage api. Then read how to post directly to blobstore (not to the servlet) with a post-save servlet callback.
Welcome to the world of Java!
I'll try my best to explain the Servlets/JSPs part. I dont know a whole lot about Google app engine.
1) Servlets are nothing but Java objects but with more priveleges. Servlets know how to handle a web request! There are many things that come to mind when we talk about web request processing:
who maps the URL to this servlet?
Who gives this servlet user request parameters?
How can I guarantee only authorized users can access this servlet?
list goes on......
Answer to all above questions is a web container. And in the world of Java only one web container rules (others might differ): Apache Tomcat.
In short, servlets are Java objects created for you by Tomcat.
Where should the servlet reside?
They reside in Tomcat.
Is there another way to do this without using a .jsp page for the file
uploading ?
You dont need a JSP to send requests to a servlet. You can use jquery, python or anything else. As long as its a valid web request.
I have set up the app engine back end for my project including
endpoints. Is there a way to send the images/video that way to the
server and still be able to retrieve a serving url to fetch the
image/video later?
See the tutorial here. Especially 'Implementing Tweet My Picture' section.
Google app engine has Java API (along with python) and the best way to submit web request to that API using Java is servlets. That's why many example are in servlets. I think.
Here's what i would do if I were you:
Setup tomcat. There are many options. So reply if you are not sure.
Deploy your handler servlet that'll use Google app engine Java API.
Send your image files to blobstore (not the servlet). See the tutorial. App engine will forward blob related information to the handler servlet you created in step 2.
Use Blobstoreservice in that servlet so that users can access that uploaded image.
Let us know if this helped.
I am new to Java & i am trying to make a Web Application which can access Client Images ,
so firstly i want to know that is it possible to create a folder in Clients temporary directory or in other drive and keep my temporary images their.
Please help me to understand the possibility of what i am trying to make.
Thanks in advance.
You need applets.
Here is some thread which gives some code of applet like one you need.
https://community.oracle.com/message/9960696#9960696
There are also some problems which author of this topic has and their resolutions.
Here is some tutorial on youtube just to start (I'm not sure if this is up to date): https://www.youtube.com/watch?v=mDDeoqKcnGc
And tutorial from Oracle's page: http://docs.oracle.com/javase/tutorial/deployment/applet/
Good luck
PS. Spring and java-ee has nothing to do with your problem since it is server side. You need client side solution. Applets or Flash or Silverlight or ...
I want to prototype a server component that accepts and handles file uploads from a mobile application (should not matter what platform the phone's running). The files in question are most likely just photos, so the file size should not be that big.
I'm looking for technology/tool/library recommendations or pointers. I'm not sure where to start. I haven't set up anything on the server-side yet so I'm not sure what I don't know. Something Java-related would definitely ease me into setting up the prototype quickly.
Thanks in advance.
You can use servlet on server-side to receive files, to generate unique names for these files and keep them preferable on file system (not on database). For example you can see
http://www.servletworld.com/servlet-tutorials/servlet-file-upload-example.html