How to serve images in e-commerce application - java

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.

Related

Most suitable location to store uploaded images using the Spring Framework

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 :)

AWS S3 and Cloudfront for storage of images

I'm using AWS S3 for storage my images and accessing them by Cloudfront. Here is mine access url formate. For example:
http://mybucket.s3.amazonaws.com/qGdyRHeptWqR5sl.jpg
I want to use thumbnail for this image. Generating thumbnails at upload time is not modern approach especially when you are required a lot of different size images. It's not good in maintenance point of view. A little change in design required to regenerate all of thumbnails again.
Is there any possibility for thumbnail image to be generated on the fly by just requesting a URL something like below:
http://mybucket.s3.amazonaws.com/thumb/200/150/qGdyRHeptWqR5sl.jpg
OR
http://mybucket.s3.amazonaws.com/qGdyRHeptWqR5sl.jpg?size=200x200
OR
http://mybucket.s3.amazonaws.com/qGdyRHeptWqR5sl.jpg?width=200&height=200
I've tried all the above url but no success. DO i need to use some image resizing plugin to do so? Do i need to request image from cloudefront & resize it then reupload it on S3?
I'm using Java as programming language please recommend me some plugin or better approach in this case.
One of possible solutions related to ngx_http_image_filter_module plugin for Nginx. You can install Nginx and configure it to resize images from S3 by request.
Here is article which describe how to do it.

Managing user images in spring web application

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.

Android application performance with soap

i am building a application for a takeaway resturant using SOAP as a webservice.
Problem:
When i try to open the application it loads every time. and if i have slow internet it will take some time which is not good for a professional application.
How can i cache the images in my mobile so it loads automatically
Possible Solution in my mind:
i think i should use the local database and sink it with internet
Use local cache system (but what if the application close).
Use arraylist to store information.
Can you guide me in that as i am stuck i do some reading but i don't feel any reliable solution on it.
You can use some libs but you can lose images if the app is closed.
Actually you can cache images with libs and save them to sdcard at the same time. You need to save Their id in database. Then take data from sdcard by id from database in case you haven't internet.

Static images in webpage from Google App Engine

I'm porting an old Java project to GAE. It has some servlets, which generate html pages with static images in them. In the original project these images are stored on the filesystem next to the servlets.
I'm trying to use GCS in the first place, I've uploaded my files and gave permissions on public read. In this case I can reach the files with their public link, I can embed these links into the HTML output. But I have a feeling that this isn't the right solution. The load time seems quite slow, like the images don't "travel internally", and I have to provide permission for every single image.
So my question is, how to get an "internal" URL for a file located on GCS in your GAE application?
I've found some Java examples, but in my case I don't think I need the image object in the source, I just need an URL to pass it on to the HTML source.
As far as I know I could just simple deploy the images with the source as resources, but there are quite many of them.
If there are other soultions, like Datastore, I'm open for that too, but I thought GCS would be the easiest.
Google Cloud Storage is as fast an option for loading images as any other. A browser reads a link and asks the server (in this case GCS) to deliver an image. There is no "internal" URL that can work faster - the speed reflects the bandwidth/distance between GCS and the browser which asked for an image.
You can speed it up by using a CDN, where your image is stored on local servers throughout the world. It only makes sense if you serve content to a very large number of users, and it is a critical part of how fast a page loads.
Another way to speed up page load time is to use image sprites instead of images. This way you cut the number of requests from a browser to a server (i.e. GCS). If you images do not change frequently, and most pages need the same "collection" of images (i.e. not shown dynamically), this is a very good solution.

Categories

Resources