• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to check the integrity of uploaded file

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
A servlet functions to upload a file from local machine to server host. But sometimes, user would close web browser or hit back button during the process of uploading a file and only part of the file was uploaded to server side. I need to remove any incomlete files but how can I check the integrity of a file. Thanks in advance. Have a nice weekend.
---Yongping
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using something like com.oreilly.servlet, you should find that it will throw an Exception you can catch (most likely unexpected end of part)?

It's fairly difficult to separate out (especially with more than one file, or multiple form elements) exactly how much of the POST data is 'the file'.. but what you Might attempt is to retrieve that HTTP header that tells you the size of the POST, and if your file is signifigantly smaller than this, you know it got chopped off.

But there's got to be a better way, right? Hmm...
 
reply
    Bookmark Topic Watch Topic
  • New Topic