Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Struts 2 - File upload - Update of file does not work

 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using struts 2 and the UploadInterceptor to upload an image for an user account, it's working. The problem is whenever I try to update the uploaded photo it does not work. Struts 2 upload interceptor just ignores my new file and leave the old picture there. The new file is uploaded to same dir and with same name as the old one. Follows a code fragment from interceptor which is called while uploading:



Any clues on this?

[]s

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The upload interceptor deletes the uploaded file; it must be copied to a new location--I don't know if simply renaming it is enough.
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Humm..

Just find a solution for my problem, follows the new fragment of code and considerations:



What I did was adding some code to check if the user had already an uploaded photo and if it has I rename it. Because I only want 1 back up I check if I already have this back up and if I have I delete it before adding the new Photo.

[]s
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just notice that sometimes the file gets locked by the server and the code I write is not able to delete or rename the files... I'll try something with timestamp but this will cause holding all uploaded photos from user..

Still accepting suggestions on this.

[]s
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic