0

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.

sergioBertolazzo
  • 585
  • 2
  • 11
  • 27
  • 1
    why aren't you using a relative file address? – Sarah Aziziyan Oct 17 '17 at 19:05
  • 1
    In the database, or in a file storage service such as Amazon S3 or Google Cloud Storage, for example. – JB Nizet Oct 17 '17 at 19:06
  • 1
    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. – Damien - Layershift Oct 17 '17 at 19:35
  • @SarahAziziyan sorry for my ignorance, I do not know exactly what "relative path" means. If you have any material explaining it would help me a lot! – sergioBertolazzo Oct 17 '17 at 19:54
  • @JBNizet I've been looking for amazon s3, but thought I could use a local file server. – sergioBertolazzo Oct 17 '17 at 19:55
  • @Damien-Layershift I am new to the jelastic environment (5 days of use) do you have any material that I can see how to make this process of define a 'volume'? – sergioBertolazzo Oct 17 '17 at 19:58
  • 4
    https://docs.jelastic.com/docker-volumes - if your node doesn't have this feature it is not based on Docker (not all node types were converted yet) – Damien - Layershift Oct 17 '17 at 20:03
  • @Damien-Layershift thank you a lot! this work fine now! How can I mark this as the right answer? – sergioBertolazzo Oct 17 '17 at 23:13
  • 2
    Glad it works well for you. I've reposted my comments as an answer so you can mark as accepted. It might help others find the solution more easily in future. – Damien - Layershift Oct 18 '17 at 06:42

1 Answers1

2

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

Damien - Layershift
  • 1,508
  • 8
  • 15