Where to store profile images that the user uploaded?

Asked

Viewed 540 times

1

I have a JAVA application that needs to store profile images that the user sent.

//no meu LOCALHOST eu uso esse caminho e funciona perfeitamente:
File arquivo = novo File("C:/myProject/uploads/profile_images");

So now I want to deploy this project, I’m using the jelastic environment and the question is:

Where these files (images) should be stored in Jelastic?

  • I’ve tried the same code, but it didn’t work.
  • I have already tried saving the files in Webcontent folder, it works perfectly, but when I expand a new file. War, the files the user sent will be overwritten.
  • I read about saving files in mysql, it’s a good practice?

Thank you for your attention.

2 answers

3


Have you considered hosting on the machine itself? (In the file system?) Because it would be a cheaper cost than the bank, because this has the cost per space higher than a machine.

The best solution will depend on your context, as you spoke in image size, I think the File System is the most suitable. Some facts you can take into consideration if it were in database:

1 - The Bank will become (perhaps considerably) larger. The simple solution would be to directly serve the images via the web server (apache and static content in directories, for example).

2 - No transactional control or timing guarantee You can delete the record in the DB and not delete the image (or the reverse). If you save the record and there is an error in Insert, for example, you will have an orphaned image in the folder.

3 - Increases the complexity of the BD, because now the backup also has to consider the table of images

  • Good afternoon Fernando, Thank you for the reply. So that’s exactly what I wanted, to record in the file system, I can do this successfully locally. However in Jelastic production environment do not know which way to save these files.

  • Yes I understand. As far as I know Jelastic has a composition filesystem that can be used with Ocker, IE, you will actually have a machine there, then you just have to see how to statically save the images there. Have a /home on your server(container) that you can save there.

2

There are certain considerable advantages to storing images in databases rather than file systems. But the cost of database hosting is higher than the cost of file hosting.

A deeper analysis of its application could help in its decision-making. Users, number of accesses and nature of the images can induce you to opt for database storage if they are small images (smaller size, less spent on hosting - remember?) for generating an access environment to these images more controlled than the file system, but if they are images with high demand of views, it would be interesting to choose to host them in file systems.

  • Good afternoon, thank you very much for the reply. In my case it would be images or videos (limited to 50MB). so I think that saving in database would not be feasible, because 20 videos of 50 MB = 1 GB of space.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.