2

I have never used uploading feature in JSF, but now I have to. I have couple of questions and they are like "for dummies" series questions. So:

1) Logged in users' pictures to DB or to filesystem of server?

2) If to server relative or fixed path or root url to db/properties and relative part to db too?

3) If to DB, how is the performance when using JPA2 + Mysql? Any cons otherwise?

4) If using server, is it secure to add new context for images to server.xml and use images from the address www.examble.com/imagesfolder/images.jpg? How to avoid the situation that everyone can see the pictures?

5) What is the best way to handle uploading? I am using Primefaces, is it good for that purpose or something else?

6) Any good tutorial or examples how to do this like a pro :)?

7) How to avoid situation that there might be files with a same name? Hashing the names or?

8) What if (really big if) I decide to share my application to two physical servers, problems with paths to pictures?

9) In my case, I have pictures, which are common to everyone and pictures "owned by logged in users. How would you implement this and why if you know that I am using Primefaces, JPA2 and Mysql and I have unlimited space in the server?

10) Very nice and hot summer to everyone!!

Sami

Sami
  • 2,311
  • 13
  • 46
  • 80

1 Answers1

2

Most of your questions are about what to do with the file once you have uploaded, that's a design matter and will depend on the software architect, the team leader or in last case on yourself. There are two good answers for the server filesystem/database file saving:

To handle problems like described in "7)" and "8)", you should use a file server and a Content Management systems. They also add more benefits than just file storage, as searching, indexing and more. Here are some examples:

To implement file uploading using JSF (Note: to do it like a pro, follow the pros ways):

Give a try these samples. If you have a problem in your coding it would be better to ask a new question.

EDIT: I forgot of number 4, thanks for the reminder. I would add a new context, as you stated, and create a Filter that will catch the requests for this new context and will redirect to a default URL.

More on this issue:

Community
  • 1
  • 1
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • What you think about number 4? Is there secure way to use "add new context"-method? I will read all of those and start to implement it today so maybe I will ask something more precise after that. Thanks! I think that I will use server instead of DB, there is couple of good reasons for that in my case. – Sami Jul 02 '12 at 11:24
  • @Sami sorry I forgot to tell you that I've updated my answer. Hope it resolves your questions :). – Luiggi Mendoza Jul 05 '12 at 02:22