FileUpload overwrite

UI Components for JSF
Post Reply
danilo.magrini
Posts: 92
Joined: 30 Mar 2011, 22:57

08 Nov 2011, 13:43

Is there any way to check if a file already exists before upload? Otherwise is this can a issue? Otherwise this could become a primefaces issue?
PrimeFaces 7.0.8 | Payara 5 | Mojarra 2.4.x
Ubuntu, Firefox

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

08 Nov 2011, 13:47

danilo.magrini wrote:Is there any way to check if a file already exists before upload? Otherwise is this can a issue? Otherwise this could become a primefaces issue?
The temporary files which fileupload generates are guaranteed to have unique names. You need to actually save this temp file yourself using the event handler so you can check for such problems yourself.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

danilo.magrini
Posts: 92
Joined: 30 Mar 2011, 22:57

08 Nov 2011, 13:56

Hi @andyba, thx for reply!

Do I have to wait upload the file (e.g. 500 Mb) to then check for duplicate name? This is infeasible!
PrimeFaces 7.0.8 | Payara 5 | Mojarra 2.4.x
Ubuntu, Firefox

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

08 Nov 2011, 14:05

danilo.magrini wrote:Hi @andyba, thx for reply!

Do I have to wait upload the file (e.g. 500 Mb) to then check for duplicate name? This is infeasible!
This can depend on the Browser but in practice the file upload event is only called when the file has been uploaded so, yes you would normally have to wait .

Why not try it and see what happens?
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

User avatar
bruno.neves
Posts: 22
Joined: 15 Jul 2010, 14:03

08 Nov 2011, 14:12

This problem happens to me too!
Checking through the FileUpload if the file is already in the folder?
Primefaces 3.4.2
Mojarra 2.1.7
Glassfish 3.1.2
Netbeans 7.1.1

danilo.magrini
Posts: 92
Joined: 30 Mar 2011, 22:57

08 Nov 2011, 14:18

andyba wrote: This can depend on the Browser but in practice the file upload event is only called when the file has been uploaded so, yes you would normally have to wait .
Why not try it and see what happens?
I've tried. So I posted on the forum. Anyway, thx for now!
PrimeFaces 7.0.8 | Payara 5 | Mojarra 2.4.x
Ubuntu, Firefox

foogaro
Posts: 4
Joined: 27 Sep 2011, 11:41

08 Nov 2011, 17:14

Description, in this case a file name, shouldn't be a discrimination to skip a process or store data.
Having this in mind, you should agree with PF uploading the file in your temporary directory and renaming it with a unique name.
What you should do is having a kind of md5-checksum, but still, you can do this, obviously, after the file was uploaded.

Cheers,
Luigi ;)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 54 guests